This commit is contained in:
Gvidas Juknevičius 2024-08-25 22:45:26 +03:00
parent f83565a402
commit 6900a19205
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 16 additions and 6 deletions

View File

@ -360,15 +360,19 @@ 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);
updated = true;
end
end
if updated then
log.info("Rebooting!");
sleep(3);
os.reboot();
end
end
end
function updater:check(branch)
local curr = os.time();
if not ((math.abs(curr - self.last_check) >= self.threshold) and (self.curr_commit_hash ~= "")) then
@ -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);

View File

@ -38,15 +38,19 @@ 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);
updated = true;
end
end
if updated then
log.info("Rebooting!");
sleep(3);
os.reboot();
end
end
end
function updater:check(branch)
local curr = os.time();
@ -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");