diff options
-rw-r--r-- | app/xdg-app-builtins-list.c | 35 | ||||
-rw-r--r-- | common/xdg-app-dir.c | 22 |
2 files changed, 23 insertions, 34 deletions
diff --git a/app/xdg-app-builtins-list.c b/app/xdg-app-builtins-list.c index 921e03e..9c8423c 100644 --- a/app/xdg-app-builtins-list.c +++ b/app/xdg-app-builtins-list.c @@ -81,33 +81,31 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo g_auto(GStrv) user = NULL; g_auto(GStrv) user_app = NULL; g_auto(GStrv) user_runtime = NULL; + g_autoptr(XdgAppDir) user_dir = NULL; + g_autoptr(XdgAppDir) system_dir = NULL; int s, u; if (print_user) { - g_autoptr(XdgAppDir) dir = NULL; + user_dir = xdg_app_dir_get (TRUE); - dir = xdg_app_dir_get (TRUE); - - if (xdg_app_dir_ensure_repo (dir, cancellable, NULL)) + if (xdg_app_dir_ensure_repo (user_dir, cancellable, NULL)) { - if (app && !xdg_app_dir_list_refs (dir, "app", &user_app, cancellable, error)) + if (app && !xdg_app_dir_list_refs (user_dir, "app", &user_app, cancellable, error)) return FALSE; - if (runtime && !xdg_app_dir_list_refs (dir, "runtime", &user_runtime, cancellable, error)) + if (runtime && !xdg_app_dir_list_refs (user_dir, "runtime", &user_runtime, cancellable, error)) return FALSE; } } if (print_system) { - g_autoptr(XdgAppDir) dir = NULL; - - dir = xdg_app_dir_get (FALSE); - if (xdg_app_dir_ensure_repo (dir, cancellable, NULL)) + system_dir = xdg_app_dir_get (FALSE); + if (xdg_app_dir_ensure_repo (system_dir, cancellable, NULL)) { - if (app && !xdg_app_dir_list_refs (dir, "app", &system_app, cancellable, error)) + if (app && !xdg_app_dir_list_refs (system_dir, "app", &system_app, cancellable, error)) return FALSE; - if (runtime && !xdg_app_dir_list_refs (dir, "runtime", &system_runtime, cancellable, error)) + if (runtime && !xdg_app_dir_list_refs (system_dir, "runtime", &system_runtime, cancellable, error)) return FALSE; } } @@ -123,7 +121,7 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo g_auto(GStrv) parts = NULL; g_autofree char *repo = NULL; gboolean is_user; - g_autoptr(XdgAppDir) dir = NULL; + XdgAppDir *dir = NULL; if (system[s] == NULL) is_user = TRUE; @@ -135,14 +133,19 @@ print_installed_refs (gboolean app, gboolean runtime, gboolean print_system, gbo is_user = TRUE; if (is_user) - ref = user[u++]; + { + ref = user[u++]; + dir = user_dir; + } else - ref = system[s++]; + { + ref = system[s++]; + dir = system_dir; + } parts = g_strsplit (ref, "/", -1); partial_ref = strchr(ref, '/') + 1; - dir = xdg_app_dir_get (is_user); repo = xdg_app_dir_get_origin (dir, ref, NULL, NULL); if (opt_show_details) diff --git a/common/xdg-app-dir.c b/common/xdg-app-dir.c index 05d7f87..d6704ae 100644 --- a/common/xdg-app-dir.c +++ b/common/xdg-app-dir.c @@ -2934,29 +2934,15 @@ xdg_app_dir_clone (XdgAppDir *self) XdgAppDir * xdg_app_dir_get_system (void) { - static XdgAppDir *system = NULL; - - if (system == NULL) - { - g_autoptr(GFile) path = xdg_app_get_system_base_dir_location (); - system = xdg_app_dir_new (path, FALSE); - } - - return g_object_ref (system); + g_autoptr(GFile) path = xdg_app_get_system_base_dir_location (); + return xdg_app_dir_new (path, FALSE); } XdgAppDir * xdg_app_dir_get_user (void) { - static XdgAppDir *user = NULL; - - if (user == NULL) - { - g_autoptr(GFile) path = xdg_app_get_user_base_dir_location (); - user = xdg_app_dir_new (path, TRUE); - } - - return g_object_ref (user); + g_autoptr(GFile) path = xdg_app_get_user_base_dir_location (); + return xdg_app_dir_new (path, TRUE); } XdgAppDir * |