7878
7979ConPrintf (" Checking for update..." )
8080
81- local scriptPath = " ."
82- local runtimePath = " ."
81+ local scriptPath
82+ local runtimePath
83+ do
84+ local currentDir = io.popen (" cd" ):read () or io.popen (" pwd" ):read () or " ."
85+ scriptPath = currentDir
86+ runtimePath = currentDir
87+ end
8388
8489-- Load and process local manifest
8590local localVer
@@ -214,7 +219,6 @@ for index, data in ipairs(updateFiles) do
214219 source = source :gsub (" {branch}" , localBranch )
215220 local fileName = scriptPath .. " /Update/" .. data .name :gsub (" [\\ /]" ," {slash}" )
216221 data .updateFileName = fileName
217- local content
218222 local zipName = source :match (" /([^/]+%.zip)$" )
219223 if zipName then
220224 if not zipFiles [zipName ] then
@@ -238,8 +242,20 @@ for index, data in ipairs(updateFiles) do
238242 ConPrintf (" Couldn't extract '%s' from '%s' (zip open failed)" , data .name , zipName )
239243 end
240244 else
241- ConPrintf (" Downloading %s... (%d of %d)" , data .name , index , # updateFiles )
242- downloadFile (source , data .name , fileName )
245+ local skipDownload
246+ local file = io.open (fileName , " rb" )
247+ if file then
248+ local content = file :read (" *all" )
249+ if data .sha1 == sha1 (content ) or data .sha1 == sha1 (content :gsub (" \n " , " \r\n " )) then
250+ ConPrintf (" Using file from previous update attempt '%s'" , fileName )
251+ skipDownload = true
252+ end
253+ file :close ()
254+ end
255+ if not skipDownload then
256+ ConPrintf (" Downloading %s... (%d of %d)" , data .name , index , # updateFiles )
257+ downloadFile (source , data .name , fileName )
258+ end
243259 end
244260 local file = io.open (fileName , " rb" )
245261 if not file then
0 commit comments