Files
studio-desktop/scripts/installer.nsh

84 lines
2.2 KiB
NSIS

!include 'LogicLib.nsh'
; The following is used to add the "/SD" flag to MessageBox so that the
; machine can restart if the uninstaller fails.
!macro customUnInstallCheckCommon
IfErrors 0 +3
DetailPrint `Uninstall was not successful. Not able to launch uninstaller!`
Return
${if} $R0 != 0
MessageBox MB_OK|MB_ICONEXCLAMATION "$(uninstallFailed): $R0" /SD IDOK
DetailPrint `Uninstall was not successful. Uninstaller error code: $R0.`
SetErrorLevel 2
Quit
${endif}
!macroend
!macro customUnInstallCheck
!insertmacro customUnInstallCheckCommon
!macroend
!macro customUnInstallCheckCurrentUser
!insertmacro customUnInstallCheckCommon
!macroend
!macro customRemoveFiles
${ifNot} ${isUpdated}
ClearErrors
FileOpen $0 "$APPDATA\ComfyUI\extra_models_config.yaml" r
var /global line
var /global lineLength
var /global prefix
var /global prefixLength
var /global prefixFirstLetter
FileRead $0 $line
StrCpy $prefix "base_path: " ; Space at the end is important to strip away correct number of letters
StrLen $prefixLength $prefix
StrCpy $prefixFirstLetter $prefix 1
StrCpy $R3 $R0
StrCpy $R0 -1
IntOp $R0 $R0 + 1
StrCpy $R2 $R3 1 $R0
StrCmp $R2 "" +2
StrCmp $R2 $R1 +2 -3
StrCpy $R0 -1
${DoUntil} ${Errors}
StrCpy $R3 0 ; Whitespace padding counter
StrLen $lineLength $line
${Do} ; Find first letter of prefix
StrCpy $R4 $line 1 $R3
${IfThen} $R4 == $prefixFirstLetter ${|} ${ExitDo} ${|}
${IfThen} $R3 > $lineLength ${|} ${ExitDo} ${|}
IntOp $R3 $R3 + 1
${Loop}
StrCpy $R2 $line $prefixLength $R3 ; Copy part from first letter to length of prefix
${If} $R2 == $prefix
StrCpy $2 $line 1024 $R3 ; Strip off whitespace padding
StrCpy $3 $2 1024 $prefixLength ; Strip off prefix
; $3 now contains value of base_path
RMDir /r /REBOOTOK "$3\.venv"
RMDir /r /REBOOTOK "$3\uv-cache"
${ExitDo} ; No need to continue, break the cycle
${EndIf}
FileRead $0 $line
${LoopUntil} 1 = 0
FileClose $0
Delete "$APPDATA\ComfyUI\extra_models_config.yaml"
Delete "$APPDATA\ComfyUI\config.json"
${endIf}
!macroend