Skip to content

Commit

Permalink
fix(nsis): remove empty resources folders on uninstall (#88)
Browse files Browse the repository at this point in the history
tauri-apps/tauri#8263

Co-authored-by: Fabian-Lars <[email protected]>
  • Loading branch information
amr-crabnebula and FabianLars authored Nov 30, 2023
1 parent 43ab529 commit d40f691
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion crates/packager/src/package/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,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
Expand Down
12 changes: 11 additions & 1 deletion crates/packager/src/package/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,19 @@ fn build_nsis_app_installer(ctx: &Context, nsis_path: &Path) -> crate::Result<Ve
data.insert("out_file", to_json(out_file));

let (resources_dirs, resources) = generate_resource_data(config)?;
data.insert("resources_dirs", to_json(resources_dirs));
data.insert("resources_dirs", to_json(&resources_dirs));
data.insert("resources", to_json(&resources));

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));

let binaries = generate_binaries_data(config)?;
data.insert("binaries", to_json(&binaries));

Expand Down

0 comments on commit d40f691

Please sign in to comment.