From 3cf4a0d7e62087b1899e74a2bb3017beebdeeef4 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 1 Jun 2015 13:28:03 +0200 Subject: [PATCH] Use xdg_app_dir_get_origin helper --- xdg-app-builtins-uninstall.c | 10 ++++------ xdg-app-builtins-update.c | 26 ++++---------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/xdg-app-builtins-uninstall.c b/xdg-app-builtins-uninstall.c index 5c21696f..470a5971 100644 --- a/xdg-app-builtins-uninstall.c +++ b/xdg-app-builtins-uninstall.c @@ -51,7 +51,6 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella g_autoptr(GFile) deploy_base = NULL; g_autoptr(GFile) arch_dir = NULL; g_autoptr(GFile) top_dir = NULL; - g_autoptr(GFile) origin = NULL; g_autoptr(OstreeRepo) repo = NULL; const char *name; const char *arch; @@ -106,8 +105,8 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella goto out; } - origin = g_file_get_child (deploy_base, "origin"); - if (!g_file_load_contents (origin, cancellable, &repository, NULL, NULL, error)) + repository = xdg_app_dir_get_origin (dir, ref, cancellable, error); + if (repository == NULL) goto out; g_debug ("dropping active ref"); @@ -181,7 +180,6 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable, g_autoptr(GFile) deploy_base = NULL; g_autoptr(GFile) arch_dir = NULL; g_autoptr(GFile) top_dir = NULL; - g_autoptr(GFile) origin = NULL; g_autoptr(OstreeRepo) repo = NULL; const char *name; const char *arch; @@ -235,8 +233,8 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable, goto out; } - origin = g_file_get_child (deploy_base, "origin"); - if (!g_file_load_contents (origin, cancellable, &repository, NULL, NULL, error)) + repository = xdg_app_dir_get_origin (dir, ref, cancellable, error); + if (repository == NULL) goto out; g_debug ("dropping active ref"); diff --git a/xdg-app-builtins-update.c b/xdg-app-builtins-update.c index 7b6a0e73..83832e5f 100644 --- a/xdg-app-builtins-update.c +++ b/xdg-app-builtins-update.c @@ -48,8 +48,6 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable gboolean ret = FALSE; GOptionContext *context; g_autoptr(XdgAppDir) dir = NULL; - g_autoptr(GFile) deploy_base = NULL; - g_autoptr(GFile) origin = NULL; const char *runtime; const char *branch = "master"; g_autofree char *previous_deployment = NULL; @@ -86,15 +84,8 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable ref = xdg_app_build_runtime_ref (runtime, branch, opt_arch); - deploy_base = xdg_app_dir_get_deploy_dir (dir, ref); - if (!g_file_query_exists (deploy_base, cancellable)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Runtime %s branch %s not installed", runtime, branch); - goto out; - } - - origin = g_file_get_child (deploy_base, "origin"); - if (!g_file_load_contents (origin, cancellable, &repository, NULL, NULL, error)) + repository = xdg_app_dir_get_origin (dir, ref, cancellable, error); + if (repository == NULL) goto out; if (!xdg_app_dir_pull (dir, repository, ref, @@ -139,8 +130,6 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE gboolean ret = FALSE; GOptionContext *context; g_autoptr(XdgAppDir) dir = NULL; - g_autoptr(GFile) deploy_base = NULL; - g_autoptr(GFile) origin = NULL; const char *app; const char *branch = "master"; g_autofree char *ref = NULL; @@ -177,15 +166,8 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE ref = xdg_app_build_app_ref (app, branch, opt_arch); - deploy_base = xdg_app_dir_get_deploy_dir (dir, ref); - if (!g_file_query_exists (deploy_base, cancellable)) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "App %s branch %s not installed", app, branch); - goto out; - } - - origin = g_file_get_child (deploy_base, "origin"); - if (!g_file_load_contents (origin, cancellable, &repository, NULL, NULL, error)) + repository = xdg_app_dir_get_origin (dir, ref, cancellable, error); + if (repository == NULL) goto out; if (!xdg_app_dir_pull (dir, repository, ref,