Enhance Windows installer update process with improved file handling and retry mechanisms
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Added a temporary path change to avoid renaming issues during the update process, ensuring smoother transitions between old and new installations. - Implemented a retry mechanism for renaming the old installation directory, increasing reliability in scenarios where files are locked. - Enhanced logging to provide clearer feedback during the installation and renaming steps, improving user experience.
This commit is contained in:
parent
2216a28ce3
commit
d7a7e798cb
@ -127,6 +127,10 @@ Var FinalInstDir
|
|||||||
!insertmacro progressStatus "Replacing Farm Control with the new version..."
|
!insertmacro progressStatus "Replacing Farm Control with the new version..."
|
||||||
DetailPrint "Replacing Farm Control with staged update..."
|
DetailPrint "Replacing Farm Control with staged update..."
|
||||||
|
|
||||||
|
; The install section ran SetOutPath into the install tree; a directory that
|
||||||
|
; is any process's working directory cannot be renamed, so move out first.
|
||||||
|
SetOutPath "$TEMP"
|
||||||
|
|
||||||
; Clear a leftover .old from a previous interrupted update.
|
; Clear a leftover .old from a previous interrupted update.
|
||||||
${If} ${FileExists} "$FinalInstDir.old"
|
${If} ${FileExists} "$FinalInstDir.old"
|
||||||
DetailPrint "Removing leftover Farm Control.old..."
|
DetailPrint "Removing leftover Farm Control.old..."
|
||||||
@ -137,34 +141,46 @@ Var FinalInstDir
|
|||||||
!insertmacro progressStatus "Waiting for Farm Control to release install files..."
|
!insertmacro progressStatus "Waiting for Farm Control to release install files..."
|
||||||
DetailPrint "Waiting to rename install directory to Farm Control.old..."
|
DetailPrint "Waiting to rename install directory to Farm Control.old..."
|
||||||
|
|
||||||
|
; Retry every 500ms; success is verified on disk rather than via the
|
||||||
|
; error flag, which Rename does not set reliably.
|
||||||
StrCpy $R7 0
|
StrCpy $R7 0
|
||||||
swap_rename_old_retry:
|
swap_rename_old_retry:
|
||||||
ClearErrors
|
|
||||||
Rename "$FinalInstDir" "$FinalInstDir.old"
|
Rename "$FinalInstDir" "$FinalInstDir.old"
|
||||||
${If} ${Errors}
|
${IfNot} ${FileExists} "$FinalInstDir"
|
||||||
IntOp $R7 $R7 + 1
|
Goto swap_rename_old_done
|
||||||
${If} $R7 < 60
|
|
||||||
Sleep 500
|
|
||||||
Goto swap_rename_old_retry
|
|
||||||
${EndIf}
|
|
||||||
!insertmacro progressFailure "Could not move the previous Farm Control installation aside."
|
|
||||||
Abort
|
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
IntOp $R7 $R7 + 1
|
||||||
|
${If} $R7 < 120
|
||||||
|
Sleep 500
|
||||||
|
Goto swap_rename_old_retry
|
||||||
|
${EndIf}
|
||||||
|
!insertmacro progressFailure "Could not move the previous Farm Control installation aside."
|
||||||
|
Abort
|
||||||
|
swap_rename_old_done:
|
||||||
|
DetailPrint "Install directory renamed to Farm Control.old"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
!insertmacro progressStatus "Activating new Farm Control installation..."
|
!insertmacro progressStatus "Activating new Farm Control installation..."
|
||||||
DetailPrint "Renaming Farm Control.new to Farm Control..."
|
DetailPrint "Renaming Farm Control.new to Farm Control..."
|
||||||
|
|
||||||
ClearErrors
|
StrCpy $R7 0
|
||||||
Rename "$INSTDIR" "$FinalInstDir"
|
swap_rename_new_retry:
|
||||||
${If} ${Errors}
|
Rename "$INSTDIR" "$FinalInstDir"
|
||||||
|
${If} ${FileExists} "$FinalInstDir"
|
||||||
|
Goto swap_rename_new_done
|
||||||
|
${EndIf}
|
||||||
|
IntOp $R7 $R7 + 1
|
||||||
|
${If} $R7 < 20
|
||||||
|
Sleep 500
|
||||||
|
Goto swap_rename_new_retry
|
||||||
|
${EndIf}
|
||||||
; Best-effort rollback so the previous install is usable again.
|
; Best-effort rollback so the previous install is usable again.
|
||||||
${If} ${FileExists} "$FinalInstDir.old"
|
${If} ${FileExists} "$FinalInstDir.old"
|
||||||
Rename "$FinalInstDir.old" "$FinalInstDir"
|
Rename "$FinalInstDir.old" "$FinalInstDir"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
!insertmacro progressFailure "Could not activate the new Farm Control installation."
|
!insertmacro progressFailure "Could not activate the new Farm Control installation."
|
||||||
Abort
|
Abort
|
||||||
${EndIf}
|
swap_rename_new_done:
|
||||||
|
|
||||||
StrCpy $INSTDIR $FinalInstDir
|
StrCpy $INSTDIR $FinalInstDir
|
||||||
!insertmacro progressLog "installer:STATUS:Update files activated"
|
!insertmacro progressLog "installer:STATUS:Update files activated"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user