diff --git a/rtmc.lua b/rtmc.lua index 4f7e0f5..775d1c3 100644 --- a/rtmc.lua +++ b/rtmc.lua @@ -360,14 +360,18 @@ rawset(__BUNDLER_FILES, "updater", function () self:update(path, url); end function updater:checkAndUpdateAll() + local updated = false; for path, entry in pairs(self.updated_files) do if self:check(entry.branch) then self:update(path, entry.url); - log.info("Rebooting!"); - sleep(3); - os.reboot(); + updated = true; end end + if updated then + log.info("Rebooting!"); + sleep(3); + os.reboot(); + end end function updater:check(branch) local curr = os.time(); @@ -411,6 +415,7 @@ rawset(__BUNDLER_FILES, "updater", function () end if fs.exists(path) then fs.copy(path, path..".bak"); + fs.delete(path); end local fd = fs.open(path, "w"); fd.write(body); diff --git a/src/updater.lua b/src/updater.lua index d6f252f..0cfc7e3 100644 --- a/src/updater.lua +++ b/src/updater.lua @@ -38,14 +38,18 @@ function updater:addEntry(path, branch, url) end function updater:checkAndUpdateAll() + local updated = false; for path, entry in pairs(self.updated_files) do if self:check(entry.branch) then self:update(path, entry.url); - log.info("Rebooting!"); - sleep(3); - os.reboot(); + updated = true; end end + if updated then + log.info("Rebooting!"); + sleep(3); + os.reboot(); + end end function updater:check(branch) @@ -98,6 +102,7 @@ function updater:update(path, url) end if fs.exists(path) then fs.copy(path, path..".bak"); + fs.delete(path); end local fd = fs.open(path, "w");