Overwriting*
authorOlav Bakke Svendsen <mail@olavbs.no>
Tue, 10 Oct 2023 11:07:12 +0000 (13:07 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Tue, 10 Oct 2023 11:07:12 +0000 (13:07 +0200)
common/dl.lua

index be38e7e21239abf5c570758d339e8d15e063b290..53d53597549f2b437a0544cc56c2e616dbce7292 100644 (file)
@@ -4,8 +4,8 @@
 -- dl path/to/file.lua             - saves to file.lua
 -- dl path/to/file.lua -o          - overwrites file.lua
 
-local from, override_flag = table.unpack({...})
-local override = override_flag == "-o"
+local from, overwrite_flag = table.unpack({...})
+local overwrite = overwrite_flag == "-o"
 
 local download = function(f,t)
   return shell.run("wget "..f.." "..t)
@@ -16,9 +16,10 @@ if not from then
 else
   local url = "https://git.olavbs.no/?p=cc.git;a=blob_plain;f="..from..";hb=HEAD"
   local to = string.match(from, "([^/]-)$")
-  if fs.exists(to) and override then
+  if fs.exists(to) and overwrite then
     local tmp = textutils.serialize(math.random(100000,999999))
     if download(url,tmp) then
+      print("Overwriting "..to)
       fs.delete(to)
       fs.move(tmp,to)
     end