more error resistance

This commit is contained in:
xomf 2024-08-18 11:50:07 -04:00
parent 4c2197919a
commit 7ce154ed44
2 changed files with 11 additions and 3 deletions

View File

@ -7,7 +7,7 @@ local require = function(path)
return __DEFAULT_IMPORT(path)
end
end
local __UPDATE_HASH = "918aa142c365e6dd2957f611deecaf6ec7bb409a"
local __UPDATE_HASH = "91dd6ccbfd182ee76b5008fe55aa8f752eaf4268"
rawset(__BUNDLER_FILES, "updater.lua", function ()
local utils = require("utils.lua")
local config = require("config.lua")
@ -31,6 +31,7 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
end
fs.copy("startup.lua", "backup.lua")
if not string.find(update_code_text, __UPDATE_HASH) then
http.post(config.ntfy_url, "Computer #" .. tostring( os.getComputerID() ) .. "updating")
local file = fs.open("startup.lua", "w")
file.write(update_code_text)
file.close()
@ -53,7 +54,10 @@ rawset(__BUNDLER_FILES, "updater.lua", function ()
end
function mod.UpdateChecker()
while true do
checkForUpdate()
local status, err = pcall(checkForUpdate)
if not status and err ~= "Terminated" then
http.post(config.ntfy_url, err, {Priority = "urgent"})
end
sleep(1)
end
end

View File

@ -29,6 +29,7 @@ local function checkForUpdate()
fs.copy("startup.lua", "backup.lua")
if not string.find(update_code_text, __UPDATE_HASH) then
http.post(config.ntfy_url, "Computer #" .. tostring( os.getComputerID() ) .. "updating")
local file = fs.open("startup.lua", "w")
file.write(update_code_text)
file.close()
@ -52,7 +53,10 @@ end
function mod.UpdateChecker()
while true do
checkForUpdate()
local status, err = pcall(checkForUpdate)
if not status and err ~= "Terminated" then
http.post(config.ntfy_url, err, {Priority = "urgent"})
end
sleep(1)
end
end