1111class UpdateManager {
1212 static GitHubRepo := " Netropolitan/AI-Text-Tools"
1313 static GitHubAPI := " https://api.github.com/repos/" . UpdateManager.GitHubRepo . " /releases/latest"
14- static CurrentVersion := " 1.4.10 "
14+ static CurrentVersion := " 1.5.0 "
1515
1616 ; Analytics endpoint - Set to empty string "" to disable analytics
1717 static AnalyticsEndpoint := " https://brew.taila07ff3.ts.net/api/ping"
@@ -300,6 +300,45 @@ class UpdateManager {
300300 return 0
301301 }
302302
303+ /**
304+ * Download file with proper redirect handling using WinHTTP and ADODB.Stream
305+ * @param {string} url - URL to download
306+ * @param {string} savePath - Local path to save file
307+ */
308+ static DownloadWithRedirect(url, savePath) {
309+ whr := ComObject(" WinHttp.WinHttpRequest.5.1" )
310+ whr.Open(" GET" , url, true )
311+ whr.SetRequestHeader(" User-Agent" , " AI-Text-Tools/" . this.CurrentVersion)
312+ whr.SetTimeouts(30000 , 30000 , 30000 , 60000 )
313+ whr.Send ()
314+ whr.WaitForResponse(60 )
315+
316+ ; Check for redirect (GitHub returns 302)
317+ if whr.Status = 302 || whr.Status = 301 {
318+ redirectUrl := whr.GetResponseHeader(" Location" )
319+ if redirectUrl {
320+ whr := ComObject(" WinHttp.WinHttpRequest.5.1" )
321+ whr.Open(" GET" , redirectUrl, true )
322+ whr.SetRequestHeader(" User-Agent" , " AI-Text-Tools/" . this.CurrentVersion)
323+ whr.SetTimeouts(30000 , 30000 , 30000 , 60000 )
324+ whr.Send ()
325+ whr.WaitForResponse(60 )
326+ }
327+ }
328+
329+ if whr.Status ! = 200 {
330+ throw Error(" HTTP " . whr.Status)
331+ }
332+
333+ ; Save binary response using ADODB.Stream
334+ stream := ComObject(" ADODB.Stream" )
335+ stream.Type := 1 ; adTypeBinary
336+ stream.Open()
337+ stream.Write (whr.ResponseBody)
338+ stream.SaveToFile(savePath, 2 ) ; adSaveCreateOverWrite
339+ stream.Close ()
340+ }
341+
303342 /**
304343 * Download update to temp folder
305344 * @param {Function} progressCallback - Optional callback(percent, status)
@@ -325,8 +364,8 @@ class UpdateManager {
325364 if progressCallback
326365 progressCallback(0 , " Connecting..." )
327366
328- ; Download file
329- Download (this.DownloadUrl, tempPath)
367+ ; Download file with proper redirect handling
368+ this.DownloadWithRedirect (this.DownloadUrl, tempPath)
330369
331370 if progressCallback
332371 progressCallback(100 , " Download complete" )
0 commit comments