From deab96c8fb8ce7afd16652f59a6b07bd928d3191 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 19 Jan 2015 12:12:30 +0100 Subject: [PATCH] Update exports on uninstall too This means we remove dangling links and re-run triggers. --- xdg-app-dir.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/xdg-app-dir.c b/xdg-app-dir.c index b06b9fc9..5029a0fa 100644 --- a/xdg-app-dir.c +++ b/xdg-app-dir.c @@ -710,6 +710,30 @@ xdg_app_export_dir (const char *app, return ret; } +static gboolean +xdg_app_dir_update_exports (XdgAppDir *self, + GCancellable *cancellable, + GError **error) +{ + gboolean ret = FALSE; + gs_unref_object GFile *exports = NULL; + + exports = xdg_app_dir_get_exports_dir (self); + + if (g_file_query_exists (exports, cancellable)) + { + if (!xdg_app_remove_dangling_symlinks (exports, cancellable, error)) + goto out; + + if (!xdg_app_dir_run_triggers (self, cancellable, error)) + goto out; + } + + ret = TRUE; + + out: + return ret; +} gboolean xdg_app_dir_deploy (XdgAppDir *self, @@ -839,14 +863,8 @@ xdg_app_dir_deploy (XdgAppDir *self, if (!xdg_app_dir_set_active (self, ref, checksum, cancellable, error)) goto out; - if (is_app && g_file_query_exists (exports, cancellable)) - { - if (!xdg_app_remove_dangling_symlinks (exports, cancellable, error)) - goto out; - - if (!xdg_app_dir_run_triggers (self, cancellable, error)) - goto out; - } + if (is_app && !xdg_app_dir_update_exports (self, cancellable, error)) + goto out; ret = TRUE; out: @@ -925,6 +943,7 @@ xdg_app_dir_undeploy (XdgAppDir *self, gs_unref_object GFile *removeddir = NULL; gs_free char *tmpname = NULL; gs_free char *active = NULL; + gboolean is_app; int i; g_assert (ref != NULL); @@ -985,6 +1004,11 @@ xdg_app_dir_undeploy (XdgAppDir *self, if (!gs_shutil_rm_rf (removeddir, cancellable, error)) goto out; + is_app = g_str_has_prefix (ref, "app"); + + if (is_app && !xdg_app_dir_update_exports (self, cancellable, error)) + goto out; + ret = TRUE; out: return ret;