Skip to content

Commit

Permalink
Fix deleting web apps on macOS whose app bundles were already removed (
Browse files Browse the repository at this point in the history
…fixes #427)
  • Loading branch information
filips123 committed Dec 8, 2023
1 parent 6f5b392 commit 57cbf78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 10 additions & 14 deletions native/src/integrations/implementation/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ fn store_icons(
Ok(())
}

fn remove_icons(classid: &str, data: &Path) -> Result<()> {
fn remove_icons(classid: &str, data: &Path) {
let directory = data.display().to_string();
let pattern = format!("{directory}/icons/hicolor/*/apps/{classid}*");

for path in glob(&pattern)?.filter_map(Result::ok) {
let _ = remove_file(path);
if let Ok(paths) = glob(&pattern) {
for path in paths.filter_map(Result::ok) {
let _ = remove_file(path);
}
}

Ok(())
}

fn create_desktop_entry(
Expand Down Expand Up @@ -312,20 +312,16 @@ fn create_startup_entry(
Ok(())
}

fn remove_desktop_entry(classid: &str, data: &Path) -> Result<()> {
fn remove_desktop_entry(classid: &str, data: &Path) {
let directory = data.join("applications");
let filename = directory.join(format!("{classid}.desktop"));

let _ = remove_file(filename);
Ok(())
}

fn remove_startup_entry(classid: &str, config: &Path) -> Result<()> {
fn remove_startup_entry(classid: &str, config: &Path) {
let directory = config.join("autostart");
let filename = directory.join(format!("{classid}.desktop"));

let _ = remove_file(filename);
Ok(())
}

//////////////////////////////
Expand Down Expand Up @@ -361,9 +357,9 @@ pub fn uninstall(args: &IntegrationUninstallArgs) -> Result<()> {
let data = &base.data_dir().to_owned();
let config = &base.config_dir().to_owned();

remove_icons(&ids.classid, data).context("Failed to remove web app icons")?;
remove_desktop_entry(&ids.classid, data).context("Failed to remove application entry")?;
remove_startup_entry(&ids.classid, config).context("Failed to remove startup entry")?;
remove_icons(&ids.classid, data);
remove_desktop_entry(&ids.classid, data);
remove_startup_entry(&ids.classid, config);
update_application_cache(data);

Ok(())
Expand Down
4 changes: 4 additions & 0 deletions native/src/integrations/implementation/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ fn remove_app_bundle(args: &IntegrationUninstallArgs) -> Result<()> {
.join("Applications")
.join(format!("{}.app", sanitize_name(&args.site.name(), &ulid)));

if !bundle.exists() {
return Ok(());
}

verify_app_is_pwa(&bundle, &format!("FFPWA-{ulid}"))?;
let _ = remove_dir_all(bundle);

Expand Down

0 comments on commit 57cbf78

Please sign in to comment.