From 5ff9acc595d55e7639019e7f560fd89d68f432ee Mon Sep 17 00:00:00 2001 From: Wires77 Date: Wed, 12 Feb 2025 22:23:11 -0600 Subject: [PATCH 1/2] Resume failed download --- src/UpdateCheck.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/UpdateCheck.lua b/src/UpdateCheck.lua index 000232ab25..b4895cb59e 100644 --- a/src/UpdateCheck.lua +++ b/src/UpdateCheck.lua @@ -214,7 +214,6 @@ for index, data in ipairs(updateFiles) do source = source:gsub("{branch}", localBranch) local fileName = scriptPath.."/Update/"..data.name:gsub("[\\/]","{slash}") data.updateFileName = fileName - local content local zipName = source:match("/([^/]+%.zip)$") if zipName then if not zipFiles[zipName] then @@ -238,8 +237,20 @@ for index, data in ipairs(updateFiles) do ConPrintf("Couldn't extract '%s' from '%s' (zip open failed)", data.name, zipName) end else - ConPrintf("Downloading %s... (%d of %d)", data.name, index, #updateFiles) - downloadFile(source, data.name, fileName) + local skipDownload + local file = io.open(fileName, "rb") + if file then + local content = file:read("*all") + if data.sha1 == sha1(content) or data.sha1 == sha1(content:gsub("\n", "\r\n")) then + ConPrintf("Using file from previous update attempt '%s'", fileName) + skipDownload = true + end + file:close() + end + if not skipDownload then + ConPrintf("Downloading %s... (%d of %d)", data.name, index, #updateFiles) + downloadFile(source, data.name, fileName) + end end local file = io.open(fileName, "rb") if not file then From 213645d374e90ffc73c44ec5d0de0fe03e61a2ca Mon Sep 17 00:00:00 2001 From: Wires77 Date: Thu, 13 Feb 2025 20:12:08 -0600 Subject: [PATCH 2/2] Get proper local directory --- src/UpdateCheck.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/UpdateCheck.lua b/src/UpdateCheck.lua index b4895cb59e..0dab75f900 100644 --- a/src/UpdateCheck.lua +++ b/src/UpdateCheck.lua @@ -78,8 +78,13 @@ end ConPrintf("Checking for update...") -local scriptPath = "." -local runtimePath = "." +local scriptPath +local runtimePath +do + local currentDir = io.popen("cd"):read() or io.popen("pwd"):read() or "." + scriptPath = currentDir + runtimePath = currentDir +end -- Load and process local manifest local localVer