| 1 | ; Hooks into the Windows installer Tauri makes (tauri.conf.json, |
| 2 | ; bundle.windows.nsis.installerHooks). |
| 3 | ; |
| 4 | ; Uninstalling with "Delete the application data" ticked takes the runner's |
| 5 | ; sandbox with it: its WSL distribution (g1t-sandbox) is registered with |
| 6 | ; Windows apart from the app's folder, so deleting the folder alone left it |
| 7 | ; behind, and g1t installed again found a sandbox it had no record of. Not |
| 8 | ; on an update (/UPDATE), which uninstalls the old version to install the |
| 9 | ; new one and keeps everything. The runner's folder is in local data, or in |
| 10 | ; roaming data where an older version set it up; either is seen to. |
| 11 | |
| 12 | !macro G1T_REMOVE_SANDBOX ROOT |
| 13 | ${If} ${FileExists} "${ROOT}\sh.g1t.desktop\runner\bin\g1t-runner.exe" |
| 14 | nsExec::Exec '"${ROOT}\sh.g1t.desktop\runner\bin\g1t-runner.exe" sandbox down --delete --state-dir "${ROOT}\sh.g1t.desktop\runner\sandbox"' |
| 15 | Pop $0 |
| 16 | ${EndIf} |
| 17 | !macroend |
| 18 | |
| 19 | !macro NSIS_HOOK_PREUNINSTALL |
| 20 | ${If} $DeleteAppDataCheckboxState = 1 |
| 21 | ${AndIf} $UpdateMode <> 1 |
| 22 | !insertmacro G1T_REMOVE_SANDBOX "$LOCALAPPDATA" |
| 23 | !insertmacro G1T_REMOVE_SANDBOX "$APPDATA" |
| 24 | ${EndIf} |
| 25 | !macroend |