From c47f089395710c42e46120ddde20df96762ff207 Mon Sep 17 00:00:00 2001 From: xomf Date: Sat, 17 Aug 2024 22:45:31 -0400 Subject: [PATCH] hopefully this will stop it from autoupdating for no reason :3 --- keypadOS.lua | 16 +++++++++++----- src/ui.lua | 2 +- src/updater.lua | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/keypadOS.lua b/keypadOS.lua index d1642ad..d1bfe48 100644 --- a/keypadOS.lua +++ b/keypadOS.lua @@ -26,11 +26,17 @@ rawset(__BUNDLER_FILES, "updater.lua", function () if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then --make backup fs.copy("startup.lua","backup.lua") - --install update - local file = fs.open("startup.lua", "w") - file.write(update_code_text) + local startup_file = fs.open("startup.lua", "r") + local startup_contents = file.readAll() file.close() - os.reboot() + if update_code_text ~= startup_contents then + local file = fs.open("startup.lua", "w") + file.write(update_code_text) + file.close() + os.reboot() + else + print("Nothing changed, not updating.") + end end print("Bad file download (core)") end @@ -175,7 +181,7 @@ rawset(__BUNDLER_FILES, "ui.lua", function () end) if not status and err ~= "Terminated" then print("Error detected: " .. err) - monitor.clear() + utils.MonReset(0.5) fs.delete("basalt.lua") fs.delete("startup.lua") fs.copy("backup.lua", "startup.lua") diff --git a/src/ui.lua b/src/ui.lua index dcbe98f..a3e4c00 100644 --- a/src/ui.lua +++ b/src/ui.lua @@ -114,7 +114,7 @@ function mod.InitUi() if not status and err ~= "Terminated" then print("Error detected: " .. err) - monitor.clear() + utils.MonReset(0.5) fs.delete("basalt.lua") fs.delete("startup.lua") fs.copy("backup.lua", "startup.lua") diff --git a/src/updater.lua b/src/updater.lua index efd5dde..559373e 100644 --- a/src/updater.lua +++ b/src/updater.lua @@ -19,11 +19,19 @@ local function checkForUpdate() --make backup fs.copy("startup.lua","backup.lua") - --install update - local file = fs.open("startup.lua", "w") - file.write(update_code_text) + local startup_file = fs.open("startup.lua", "r") + local startup_contents = file.readAll() file.close() - os.reboot() + + if update_code_text ~= startup_contents then + local file = fs.open("startup.lua", "w") + file.write(update_code_text) + file.close() + os.reboot() + else + print("Nothing changed, not updating.") + end + end print("Bad file download (core)") end