Bug fixes for auto-update functionality

main
Yuriy 2 years ago
parent 0e872711f0
commit 43c47e3cb6

@ -12,7 +12,6 @@ if(InStr(A_ScriptName, ".ahk")){
ErrorLoggingDirectory = %1% ErrorLoggingDirectory = %1%
; Add menus to the toolbar icon ; Add menus to the toolbar icon
Menu, tray, NoStandard ; remove standard tray Menu, tray, NoStandard ; remove standard tray
@ -32,7 +31,7 @@ global UpdateVersionNumber
;---Notes/Extra Info/#Includes------------------------------------------------------ ;---Notes/Extra Info/#Includes------------------------------------------------------
ScriptName = Freedomain Social Media Poster ScriptName = Freedomain Social Media Poster
ScriptVersion = 2.72 ScriptVersion = 2.71
FullScriptName := ScriptName . " " . ScriptVersion FullScriptName := ScriptName . " " . ScriptVersion
;---ToDo--- ;---ToDo---
@ -191,10 +190,12 @@ if(ErrorLoggingDirectory = "LastPost"){
} }
; if passed argument is .exe file, then script has just been udpated and we need to move the old version ; if passed argument is .exe file, then script has just been udpated and we need to move the old version
if(InStr(ErrorLoggingDirectory,ScriptName, and InStr(ErrorLoggingDirectory,".exe"))){ if(InStr(ErrorLoggingDirectory,ScriptName) and InStr(ErrorLoggingDirectory,".exe")){
SaveOrPostProgress(Message:="Starting Up: Moving Old Version",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
; create backups folder if it doesn't exist ; create backups folder if it doesn't exist
BackupsFolder = %LibFolder%\Backups\%ErrorLoggingDirectory% BackupsFolder = %LibFolder%\Backups\
; Msgbox % "BackupsFolder: " BackupsFolder
if(!FileExist(BackupsFolder)){ if(!FileExist(BackupsFolder)){
FileCreateDir, %BackupsFolder% FileCreateDir, %BackupsFolder%
@ -202,13 +203,22 @@ if(InStr(ErrorLoggingDirectory,ScriptName, and InStr(ErrorLoggingDirectory,".exe
; move old version to backups folder, overwrite if name conflict ; move old version to backups folder, overwrite if name conflict
FileMove, %ErrorLoggingDirectory%, %BackupsFolder%\*, 1 FileMove, %ErrorLoggingDirectory%, %BackupsFolder%\*, 1
if(ErrorLevel){ ; most likely because the old version hasn't finished exiting yet
MsgBox,,Update Successful, Previous version was backed up to: %BackupsFolder% sleep, 2000
FileMove, %ErrorLoggingDirectory%, %BackupsFolder%\*, 1
if(ErrorLevel){
MsgBox,,Update Successful, Update was successful`, but unable to move old version to the Backups folder.`nPlease move it or delete it manually.
}
}
ToolTip
; MsgBox,,Update Successful, Previous version was backed up to: %BackupsFolder%
} }
if(StrLen(ErrorLoggingDirectory) > 5){ ; if argument was passed in, read contents from that directory if(StrLen(ErrorLoggingDirectory) > 5 and !InStr(ErrorLoggingDirectory, ".exe")){ ; if argument was passed in, read contents from that directory
SaveOrPostProgress(Message:="Starting Up: Reading Information from Files",PostType:="Tooltip")
SkipUpdateCheckThisRun := 1 SkipUpdateCheckThisRun := 1
if(InStr(ErrorLoggingDirectory, "VideoLinks.ini")){ ;PASSED IN FROM VIDEO UPLOADER if(InStr(ErrorLoggingDirectory, "VideoLinks.ini")){ ;PASSED IN FROM VIDEO UPLOADER
@ -273,6 +283,7 @@ if(StrLen(ErrorLoggingDirectory) > 5){ ; if argument was passed in, read content
ReadWebsiteStatuses() ; Read .ini file of post statuses for each site ReadWebsiteStatuses() ; Read .ini file of post statuses for each site
} }
; Tooltip
} }

@ -70,26 +70,16 @@ UpdateScript(){
exename := parsed.1.assets.1.name exename := parsed.1.assets.1.name
exeURL := parsed.1.assets.1.browser_download_url exeURL := parsed.1.assets.1.browser_download_url
Msgbox % "UpdateVersionNumber: " UpdateVersionNumber ; Msgbox % "UpdateVersionNumber: " UpdateVersionNumber
; msgbox, Version: %Version% ; msgbox, Version: %Version%
Msgbox % "ChangeLog: " ChangeLog ; Msgbox % "ChangeLog: " ChangeLog
Msgbox % "exeURL: " exeURL ; Msgbox % "exeURL: " exeURL
Msgbox % "exename: " exename ; Msgbox % "exename: " exename
ExeName := StrReplace(exename, ".exe", "") ExeName := StrReplace(exename, ".exe", "")
UpdateExeName = %exename% %UpdateVersionNumber%.exe UpdateExeName = %exename% %UpdateVersionNumber%.exe
UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName% UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName%
; Msgbox % "ChangelogIniFilepath: " ChangelogIniFilepath
; Msgbox % "ScriptSettingsSection: " ScriptSettingsSection
; IniRead, Changelog, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog, %A_Space%
; Changelog := StrReplace(Changelog, "--", "`n-")
; IniRead, UpdateVersion, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion, %A_Space%
if(ScriptVersion = UpdateVersionNumber){ if(ScriptVersion = UpdateVersionNumber){
; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable ; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
MsgBox, You are Up-To-Date MsgBox, You are Up-To-Date
@ -109,7 +99,7 @@ UpdateScript(){
SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName% Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName%
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath% UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, %UpdateExeFilepath% %A_ScriptFullPath% run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ExitApp ExitApp
} }
return return

Loading…
Cancel
Save