From 7ce154ed4496bac13f48d1bf0a0d33ea694553cd Mon Sep 17 00:00:00 2001 From: xomf Date: Sun, 18 Aug 2024 11:50:07 -0400 Subject: [PATCH] more error resistance --- keypadOS.lua | 8 ++++++-- src/updater.lua | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/keypadOS.lua b/keypadOS.lua index 70f5919..a576b96 100644 --- a/keypadOS.lua +++ b/keypadOS.lua @@ -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 diff --git a/src/updater.lua b/src/updater.lua index 57ef886..925b638 100644 --- a/src/updater.lua +++ b/src/updater.lua @@ -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