summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-04-21 20:19:01 +0200
committerAlexander Larsson <alexl@redhat.com>2016-04-21 20:19:01 +0200
commit91eda8919e06d6d7752a522e4161fb7d2611cbed (patch)
treeffdb0e79d451584a71e46c106540488303799e12 /common
parent21dd53d1ff7541c4dc3e95da3ae15f5eb2a62778 (diff)
downloadxdg-app-91eda8919e06d6d7752a522e4161fb7d2611cbed.tar.gz
common: Move duplicated code into xdg_app_dir_deploy_update
Diffstat (limited to 'common')
-rw-r--r--common/xdg-app-dir.c52
-rw-r--r--common/xdg-app-dir.h1
2 files changed, 34 insertions, 19 deletions
diff --git a/common/xdg-app-dir.c b/common/xdg-app-dir.c
index 79bff57..3bdfd2b 100644
--- a/common/xdg-app-dir.c
+++ b/common/xdg-app-dir.c
@@ -2184,41 +2184,57 @@ gboolean
xdg_app_dir_deploy_update (XdgAppDir *self,
const char *ref,
const char *checksum_or_latest,
- gboolean *was_updated,
GCancellable *cancellable,
GError **error)
{
g_autofree char *previous_deployment = NULL;
g_autoptr(GError) my_error = NULL;
+ g_auto(GLnxLockFile) lock = GLNX_LOCK_FILE_INIT;
+
+ if (!xdg_app_dir_lock (self, &lock,
+ cancellable, error))
+ return FALSE;
previous_deployment = xdg_app_dir_read_active (self, ref, cancellable);
- if (!xdg_app_dir_deploy (self, ref, checksum_or_latest, cancellable, &my_error))
+ if (!xdg_app_dir_deploy (self, ref, checksum_or_latest,
+ cancellable, &my_error))
{
- if (g_error_matches (my_error, XDG_APP_DIR_ERROR, XDG_APP_DIR_ERROR_ALREADY_DEPLOYED))
- {
- if (was_updated)
- *was_updated = FALSE;
- return TRUE;
- }
+ if (g_error_matches (my_error, XDG_APP_DIR_ERROR,
+ XDG_APP_DIR_ERROR_ALREADY_DEPLOYED))
+ return TRUE;
g_propagate_error (error, my_error);
return FALSE;
}
- else
+
+ if (previous_deployment != NULL)
{
- if (was_updated)
- *was_updated = TRUE;
+ if (!xdg_app_dir_undeploy (self, ref, previous_deployment,
+ FALSE,
+ cancellable, error))
+ return FALSE;
+ }
- if (previous_deployment != NULL)
- {
- if (!xdg_app_dir_undeploy (self, ref, previous_deployment,
- FALSE,
- cancellable, error))
- return FALSE;
- }
+ if (g_str_has_prefix (ref, "app/"))
+ {
+ g_auto(GStrv) ref_parts = g_strsplit (ref, "/", -1);
+
+ if (!xdg_app_dir_update_exports (self, ref_parts[1], cancellable, error))
+ return FALSE;
}
+ /* Release lock before doing prune */
+ glnx_release_lock_file (&lock);
+
+ if (!xdg_app_dir_prune (self, cancellable, error))
+ return FALSE;
+
+ if (!xdg_app_dir_mark_changed (self, error))
+ return FALSE;
+
+ xdg_app_dir_cleanup_removed (self, cancellable, NULL);
+
return TRUE;
}
diff --git a/common/xdg-app-dir.h b/common/xdg-app-dir.h
index 7665fc7..d94531f 100644
--- a/common/xdg-app-dir.h
+++ b/common/xdg-app-dir.h
@@ -209,7 +209,6 @@ gboolean xdg_app_dir_deploy (XdgAppDir *self,
gboolean xdg_app_dir_deploy_update (XdgAppDir *self,
const char *ref,
const char *checksum,
- gboolean *was_updated,
GCancellable *cancellable,
GError **error);
gboolean xdg_app_dir_undeploy (XdgAppDir *self,