diff --git a/xdg-app-builtins-install.c b/xdg-app-builtins-install.c index 06823ac5..b504dd50 100644 --- a/xdg-app-builtins-install.c +++ b/xdg-app-builtins-install.c @@ -167,7 +167,7 @@ xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, G if (!xdg_app_dir_make_current_ref (dir, ref, cancellable, error)) goto out; - if (!xdg_app_dir_update_exports (dir, cancellable, error)) + if (!xdg_app_dir_update_exports (dir, app, cancellable, error)) goto out; xdg_app_dir_cleanup_removed (dir, cancellable, NULL); diff --git a/xdg-app-builtins-make-current.c b/xdg-app-builtins-make-current.c index b32e8e90..8ace856a 100644 --- a/xdg-app-builtins-make-current.c +++ b/xdg-app-builtins-make-current.c @@ -67,6 +67,9 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab if (!xdg_app_dir_make_current_ref (dir, ref, cancellable, error)) goto out; + if (!xdg_app_dir_update_exports (dir, app, cancellable, error)) + goto out; + ret = TRUE; out: diff --git a/xdg-app-builtins-uninstall.c b/xdg-app-builtins-uninstall.c index 2357c4d5..5a664d3d 100644 --- a/xdg-app-builtins-uninstall.c +++ b/xdg-app-builtins-uninstall.c @@ -244,7 +244,7 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable, if (!gs_shutil_rm_rf (deploy_base, cancellable, error)) goto out; - if (!xdg_app_dir_update_exports (dir, cancellable, error)) + if (!xdg_app_dir_update_exports (dir, name, cancellable, error)) goto out; g_debug ("cleaning up empty directories"); diff --git a/xdg-app-builtins-update.c b/xdg-app-builtins-update.c index 3311c9ee..d379469d 100644 --- a/xdg-app-builtins-update.c +++ b/xdg-app-builtins-update.c @@ -196,7 +196,7 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE goto out; } - if (!xdg_app_dir_update_exports (dir, cancellable, error)) + if (!xdg_app_dir_update_exports (dir, app, cancellable, error)) goto out; ret = TRUE; diff --git a/xdg-app-dir.c b/xdg-app-dir.c index 0cd84f60..b5423c98 100644 --- a/xdg-app-dir.c +++ b/xdg-app-dir.c @@ -1095,23 +1095,50 @@ xdg_app_export_dir (GFile *source, gboolean xdg_app_dir_update_exports (XdgAppDir *self, + const char *changed_app, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; gs_unref_object GFile *exports = NULL; + gs_free char *current_ref = NULL; + gs_free char *active_id = NULL; + gs_free char *symlink_prefix = 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 (!gs_file_ensure_directory (exports, TRUE, cancellable, error)) + goto out; - if (!xdg_app_dir_run_triggers (self, cancellable, error)) - goto out; + if (changed_app && + (current_ref = xdg_app_dir_current_ref (self, changed_app, cancellable)) && + (active_id = xdg_app_dir_read_active (self, current_ref, cancellable))) + { + gs_unref_object GFile *deploy_base = NULL; + gs_unref_object GFile *active = NULL; + gs_unref_object GFile *export = NULL; + + deploy_base = xdg_app_dir_get_deploy_dir (self, current_ref); + active = g_file_get_child (deploy_base, active_id); + export = g_file_get_child (active, "export"); + + if (g_file_query_exists (export, cancellable)) + { + symlink_prefix = g_build_filename ("..", "app", changed_app, "current", "active", "export", NULL); + if (!xdg_app_export_dir (export, exports, + symlink_prefix, + cancellable, + error)) + goto out; + } } + 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: @@ -1238,8 +1265,6 @@ xdg_app_dir_deploy (XdgAppDir *self, export = g_file_get_child (checkoutdir, "export"); if (g_file_query_exists (export, cancellable)) { - gs_free char *relative_path = NULL; - gs_free char *symlink_prefix = NULL; gs_strfreev char **ref_parts = NULL; ref_parts = g_strsplit (ref, "/", -1); @@ -1248,15 +1273,6 @@ xdg_app_dir_deploy (XdgAppDir *self, cancellable, error)) goto out; - - relative_path = g_file_get_relative_path (self->basedir, export); - symlink_prefix = g_build_filename ("..", relative_path, NULL); - - if (!xdg_app_export_dir (export, exports, - symlink_prefix, - cancellable, - error)) - goto out; } if (!xdg_app_dir_set_active (self, ref, checksum, cancellable, error)) diff --git a/xdg-app-dir.h b/xdg-app-dir.h index f0a63607..6537499e 100644 --- a/xdg-app-dir.h +++ b/xdg-app-dir.h @@ -97,6 +97,7 @@ gboolean xdg_app_dir_undeploy (XdgAppDir *self, GCancellable *cancellable, GError **error); gboolean xdg_app_dir_update_exports (XdgAppDir *self, + const char *app, GCancellable *cancellable, GError **error); gboolean xdg_app_dir_prune (XdgAppDir *self,