forked from Mirrors/flatpak-builder
common: Move duplicated code into xdg_app_dir_deploy_update
parent
21dd53d1ff
commit
91eda8919e
|
@ -78,9 +78,7 @@ do_update (XdgAppDir* dir,
|
|||
g_autofree char *ref = NULL;
|
||||
g_autofree char *repository = NULL;
|
||||
g_auto(GStrv) subpaths = NULL;
|
||||
gboolean was_updated = FALSE;
|
||||
gboolean is_app;
|
||||
g_auto(GLnxLockFile) lock = GLNX_LOCK_FILE_INIT;
|
||||
|
||||
ref = xdg_app_dir_find_installed_ref (dir,
|
||||
name,
|
||||
|
@ -108,28 +106,7 @@ do_update (XdgAppDir* dir,
|
|||
|
||||
if (!opt_no_deploy)
|
||||
{
|
||||
if (!xdg_app_dir_lock (dir, &lock,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_deploy_update (dir, ref, opt_commit, &was_updated, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (was_updated && is_app)
|
||||
{
|
||||
if (!xdg_app_dir_update_exports (dir, name, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glnx_release_lock_file (&lock);
|
||||
}
|
||||
|
||||
if (was_updated)
|
||||
{
|
||||
if (!xdg_app_dir_prune (dir, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!xdg_app_dir_mark_changed (dir, error))
|
||||
if (!xdg_app_dir_deploy_update (dir, ref, opt_commit, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 (was_updated)
|
||||
*was_updated = TRUE;
|
||||
|
||||
if (previous_deployment != NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1092,8 +1092,6 @@ xdg_app_installation_update (XdgAppInstallation *self,
|
|||
g_autoptr(OstreeAsyncProgress) ostree_progress = NULL;
|
||||
g_autofree char *remote_name = NULL;
|
||||
XdgAppInstalledRef *result = NULL;
|
||||
gboolean was_updated = FALSE;
|
||||
g_auto(GLnxLockFile) lock = GLNX_LOCK_FILE_INIT;
|
||||
g_auto(GStrv) subpaths = NULL;
|
||||
|
||||
ref = xdg_app_compose_ref (kind == XDG_APP_REF_KIND_APP, name, branch, arch, error);
|
||||
|
@ -1140,35 +1138,13 @@ xdg_app_installation_update (XdgAppInstallation *self,
|
|||
|
||||
if ((flags & XDG_APP_UPDATE_FLAGS_NO_DEPLOY) == 0)
|
||||
{
|
||||
if (!xdg_app_dir_lock (dir_clone, &lock,
|
||||
cancellable, error))
|
||||
if (!xdg_app_dir_deploy_update (dir_clone, ref, NULL,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!xdg_app_dir_deploy_update (dir_clone, ref, NULL, &was_updated, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (was_updated && kind == XDG_APP_REF_KIND_APP)
|
||||
{
|
||||
if (!xdg_app_dir_update_exports (dir_clone, name, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
result = get_ref (self, ref, cancellable);
|
||||
|
||||
glnx_release_lock_file (&lock);
|
||||
|
||||
if (was_updated)
|
||||
{
|
||||
if (!xdg_app_dir_prune (dir_clone, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (!xdg_app_dir_mark_changed (dir_clone, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
xdg_app_dir_cleanup_removed (dir_clone, cancellable, NULL);
|
||||
|
||||
out:
|
||||
if (main_context)
|
||||
g_main_context_pop_thread_default (main_context);
|
||||
|
|
Loading…
Reference in New Issue