summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-04-21 21:32:49 +0200
committerAlexander Larsson <alexl@redhat.com>2016-04-22 08:55:41 +0200
commit4261057e2a0531db759b0e29292b352ae2f43634 (patch)
tree3ecc8970ce968e524e5a33d9f4ba2f8761139070 /app
parent7d509ab93a83a9d6662ee201f3657e2f584b7eda (diff)
downloadxdg-app-4261057e2a0531db759b0e29292b352ae2f43634.tar.gz
common: Don't use singletons for the system/user XdgAppDirs
Without this we never finalize them and can't e.g. remote temporary files.
Diffstat (limited to 'app')
-rw-r--r--app/xdg-app-builtins-list.c35
1 files changed, 19 insertions, 16 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)