Skip to content

Commit

Permalink
feat: Custom uninstall logic (#279)
Browse files Browse the repository at this point in the history
* Testing

* Testing

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding script to remove directories and files

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* Adding snippet

* trying define

* trying define

* trying define

* trying define

* trying define

* trying define

* Final code

* Correcting path

* fixing path

* fixing path

---------

Co-authored-by: Oto Ciulis <[email protected]>
  • Loading branch information
oto-ciulis-tt and otociulis authored Nov 25, 2024
1 parent 85e553b commit ef8df3d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
82 changes: 82 additions & 0 deletions scripts/installer.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
!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"
${endIf}
!macroend
3 changes: 3 additions & 0 deletions todesktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
"filesForDistribution": ["!assets/**", "!dist/**", "!src/**", "!scripts/**", "!.yarn/**", "!.yarnrc.yml"],
"mac": {
"additionalBinariesToSign": ["./assets/uv/macos/uv", "./assets/uv/macos/uvx"]
},
"windows": {
"nsisInclude": "./scripts/installer.nsh"
}
}

0 comments on commit ef8df3d

Please sign in to comment.