mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-18 16:11:38 +03:00
fix(bundler/nsis): remove empty resources folders on uninstall (#8263)
* fix(bundler/nsis): remove empty resources folders on uninstall * make clippy happy for once
This commit is contained in:
parent
8accd6940e
commit
f26d9f0884
7
.changes/nsis-leftover-dirs.md
Normal file
7
.changes/nsis-leftover-dirs.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"@tauri-apps/cli": patch:bug
|
||||
"tauri-cli": patch:bug
|
||||
"tauri-bundler": patch:bug
|
||||
---
|
||||
|
||||
Fixes an issue in the NSIS installer which caused the uninstallation to leave empty folders on the system if the `resources` feature was used.
|
@ -303,6 +303,17 @@ fn build_nsis_app_installer(
|
||||
let resources = generate_resource_data(settings)?;
|
||||
let resources_dirs =
|
||||
std::collections::HashSet::<PathBuf>::from_iter(resources.values().map(|r| r.0.to_owned()));
|
||||
|
||||
let mut resources_ancestors = resources_dirs
|
||||
.iter()
|
||||
.flat_map(|p| p.ancestors())
|
||||
.collect::<Vec<_>>();
|
||||
resources_ancestors.sort_unstable();
|
||||
resources_ancestors.dedup();
|
||||
resources_ancestors.sort_by_key(|p| std::cmp::Reverse(p.components().count()));
|
||||
resources_ancestors.pop(); // Last one is always ""
|
||||
|
||||
data.insert("resources_ancestors", to_json(resources_ancestors));
|
||||
data.insert("resources_dirs", to_json(resources_dirs));
|
||||
data.insert("resources", to_json(&resources));
|
||||
|
||||
|
@ -533,7 +533,6 @@ Section Install
|
||||
|
||||
; Copy resources
|
||||
{{#each resources_dirs}}
|
||||
; `\\` is not a typo.
|
||||
CreateDirectory "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
{{#each resources}}
|
||||
@ -623,7 +622,6 @@ Section Uninstall
|
||||
; Delete resources
|
||||
{{#each resources}}
|
||||
Delete "$INSTDIR\\{{this.[1]}}"
|
||||
RMDir "$INSTDIR\\{{this.[0]}}"
|
||||
{{/each}}
|
||||
|
||||
; Delete external binaries
|
||||
@ -634,7 +632,14 @@ Section Uninstall
|
||||
; Delete uninstaller
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
|
||||
RMDir "$INSTDIR"
|
||||
${If} $DeleteAppDataCheckboxState == 1
|
||||
RMDir /R /REBOOTOK "$INSTDIR"
|
||||
${Else}
|
||||
{{#each resources_ancestors}}
|
||||
RMDir /REBOOTOK "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
RMDir "$INSTDIR"
|
||||
${EndIf}
|
||||
|
||||
; Remove start menu shortcut
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
||||
|
Loading…
Reference in New Issue
Block a user