mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-23 01:12:32 -04:00
decomposed: Convert more FlatpakDir APIs to use FlatpakDecomposed
This commit is contained in:
committed by
Alexander Larsson
parent
b111965640
commit
674cc1a60a
@@ -668,11 +668,11 @@ gboolean flatpak_dir_make_current_ref (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_list_deployed (FlatpakDir *self,
|
||||
const char *ref,
|
||||
char ***deployed_checksums,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_list_deployed (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
char ***deployed_checksums,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_lock (FlatpakDir *self,
|
||||
GLnxLockFile *lockfile,
|
||||
GCancellable *cancellable,
|
||||
@@ -758,7 +758,7 @@ gboolean flatpak_dir_update (FlatpakDir *self,
|
||||
gboolean app_hint,
|
||||
gboolean install_hint,
|
||||
FlatpakRemoteState *state,
|
||||
const char *ref,
|
||||
FlatpakDecomposed *ref,
|
||||
const char *checksum_or_latest,
|
||||
const char **opt_subpaths,
|
||||
const char **opt_previous_ids,
|
||||
@@ -769,28 +769,28 @@ gboolean flatpak_dir_update (FlatpakDir *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_uninstall (FlatpakDir *self,
|
||||
const char *ref,
|
||||
FlatpakDecomposed *ref,
|
||||
FlatpakHelperUninstallFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_undeploy (FlatpakDir *self,
|
||||
const char *ref,
|
||||
const char *checksum,
|
||||
gboolean is_update,
|
||||
gboolean force_remove,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
const char *ref,
|
||||
gboolean force_remove,
|
||||
gboolean *was_deployed_out,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_remove_ref (FlatpakDir *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_undeploy (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
const char *checksum,
|
||||
gboolean is_update,
|
||||
gboolean force_remove,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
gboolean force_remove,
|
||||
gboolean *was_deployed_out,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_remove_ref (FlatpakDir *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean flatpak_dir_update_exports (FlatpakDir *self,
|
||||
const char *app,
|
||||
GCancellable *cancellable,
|
||||
|
||||
@@ -8417,7 +8417,7 @@ flatpak_dir_deploy_install (FlatpakDir *self,
|
||||
remove_ref_from_remote = g_strdup (old_origin);
|
||||
|
||||
g_debug ("Removing old deployment for reinstall");
|
||||
if (!flatpak_dir_undeploy (self, flatpak_decomposed_get_ref (ref), old_active,
|
||||
if (!flatpak_dir_undeploy (self, ref, old_active,
|
||||
TRUE, FALSE,
|
||||
cancellable, error))
|
||||
goto out;
|
||||
@@ -8540,7 +8540,7 @@ flatpak_dir_deploy_update (FlatpakDir *self,
|
||||
return FALSE;
|
||||
|
||||
if (old_active &&
|
||||
!flatpak_dir_undeploy (self, flatpak_decomposed_get_ref (ref), old_active,
|
||||
!flatpak_dir_undeploy (self, ref, old_active,
|
||||
TRUE, FALSE,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
@@ -9540,7 +9540,7 @@ flatpak_dir_update (FlatpakDir *self,
|
||||
gboolean app_hint,
|
||||
gboolean install_hint,
|
||||
FlatpakRemoteState *state,
|
||||
const char *ref_str,
|
||||
FlatpakDecomposed *ref,
|
||||
const char *commit,
|
||||
const char **opt_subpaths,
|
||||
const char **opt_previous_ids,
|
||||
@@ -9558,10 +9558,6 @@ flatpak_dir_update (FlatpakDir *self,
|
||||
g_autofree const char **old_subpaths = NULL;
|
||||
gboolean is_oci;
|
||||
|
||||
g_autoptr(FlatpakDecomposed) ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* This is calculated in check_for_update */
|
||||
g_assert (commit != NULL);
|
||||
|
||||
@@ -9802,7 +9798,7 @@ flatpak_dir_update (FlatpakDir *self,
|
||||
|
||||
gboolean
|
||||
flatpak_dir_uninstall (FlatpakDir *self,
|
||||
const char *ref_str,
|
||||
FlatpakDecomposed *ref,
|
||||
FlatpakHelperUninstallFlags flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
@@ -9817,10 +9813,6 @@ flatpak_dir_uninstall (FlatpakDir *self,
|
||||
gboolean keep_ref = flags & FLATPAK_HELPER_UNINSTALL_FLAGS_KEEP_REF;
|
||||
gboolean force_remove = flags & FLATPAK_HELPER_UNINSTALL_FLAGS_FORCE_REMOVE;
|
||||
|
||||
g_autoptr(FlatpakDecomposed) ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
|
||||
name = flatpak_decomposed_dup_id (ref);
|
||||
|
||||
if (flatpak_dir_use_system_helper (self, NULL))
|
||||
@@ -9913,7 +9905,7 @@ flatpak_dir_uninstall (FlatpakDir *self,
|
||||
if (!flatpak_dir_update_deploy_ref (self, flatpak_decomposed_get_ref (ref), NULL, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_dir_undeploy_all (self, flatpak_decomposed_get_ref (ref), force_remove, &was_deployed, cancellable, error))
|
||||
if (!flatpak_dir_undeploy_all (self, ref, force_remove, &was_deployed, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!keep_ref &&
|
||||
@@ -10077,11 +10069,11 @@ out:
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_dir_list_deployed (FlatpakDir *self,
|
||||
const char *ref_str,
|
||||
char ***deployed_ids,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
flatpak_dir_list_deployed (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
char ***deployed_ids,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
@@ -10092,10 +10084,6 @@ flatpak_dir_list_deployed (FlatpakDir *self,
|
||||
g_autoptr(GFileInfo) child_info = NULL;
|
||||
g_autoptr(GError) my_error = NULL;
|
||||
|
||||
g_autoptr(FlatpakDecomposed) ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
|
||||
deploy_base = flatpak_dir_get_deploy_dir (self, ref);
|
||||
|
||||
ids = g_ptr_array_new_with_free_func (g_free);
|
||||
@@ -10173,13 +10161,13 @@ dir_is_locked (GFile *dir)
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_dir_undeploy (FlatpakDir *self,
|
||||
const char *ref_str,
|
||||
const char *active_id,
|
||||
gboolean is_update,
|
||||
gboolean force_remove,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
flatpak_dir_undeploy (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
const char *active_id,
|
||||
gboolean is_update,
|
||||
gboolean force_remove,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
g_autoptr(GFile) checkoutdir = NULL;
|
||||
@@ -10192,10 +10180,6 @@ flatpak_dir_undeploy (FlatpakDir *self,
|
||||
g_autoptr(GError) child_error = NULL;
|
||||
int i, retry;
|
||||
|
||||
g_autoptr(FlatpakDecomposed) ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_assert (ref != NULL);
|
||||
g_assert (active_id != NULL);
|
||||
|
||||
@@ -10222,7 +10206,7 @@ flatpak_dir_undeploy (FlatpakDir *self,
|
||||
/* We're removing the active deployment, start by repointing that
|
||||
to another deployment if one exists */
|
||||
|
||||
if (!flatpak_dir_list_deployed (self, flatpak_decomposed_get_ref (ref),
|
||||
if (!flatpak_dir_list_deployed (self, ref,
|
||||
&deployed_ids,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
@@ -10309,12 +10293,12 @@ flatpak_dir_undeploy (FlatpakDir *self,
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
const char *ref_str,
|
||||
gboolean force_remove,
|
||||
gboolean *was_deployed_out,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
FlatpakDecomposed *ref,
|
||||
gboolean force_remove,
|
||||
gboolean *was_deployed_out,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_auto(GStrv) deployed = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
@@ -10324,17 +10308,13 @@ flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
int i;
|
||||
gboolean was_deployed;
|
||||
|
||||
g_autoptr(FlatpakDecomposed) ref = flatpak_decomposed_new_from_ref (ref_str, error);
|
||||
if (ref == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_dir_list_deployed (self, flatpak_decomposed_get_ref (ref), &deployed, cancellable, error))
|
||||
if (!flatpak_dir_list_deployed (self, ref, &deployed, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; deployed[i] != NULL; i++)
|
||||
{
|
||||
g_debug ("undeploying %s", deployed[i]);
|
||||
if (!flatpak_dir_undeploy (self, flatpak_decomposed_get_ref (ref), deployed[i], FALSE, force_remove, cancellable, error))
|
||||
if (!flatpak_dir_undeploy (self, ref, deployed[i], FALSE, force_remove, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -10395,11 +10375,11 @@ flatpak_dir_undeploy_all (FlatpakDir *self,
|
||||
* Returns: %TRUE if removing the ref succeeded, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
flatpak_dir_remove_ref (FlatpakDir *self,
|
||||
const char *remote_name,
|
||||
const char *ref,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
flatpak_dir_remove_ref (FlatpakDir *self,
|
||||
const char *remote_name,
|
||||
const char *ref, /* NOTE: Not necessarily a app/runtime ref */
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
if (flatpak_dir_use_system_helper (self, NULL))
|
||||
{
|
||||
@@ -12769,11 +12749,10 @@ flatpak_dir_cleanup_undeployed_refs (FlatpakDir *self,
|
||||
|
||||
for (; i < undeployed_refs->len; ++i)
|
||||
{
|
||||
FlatpakDecomposed *decomposed = g_ptr_array_index (undeployed_refs, i);
|
||||
const gchar *ref = flatpak_decomposed_get_ref (decomposed);
|
||||
g_autofree gchar *remote = flatpak_decomposed_dup_remote (decomposed);
|
||||
FlatpakDecomposed *ref = g_ptr_array_index (undeployed_refs, i);
|
||||
g_autofree gchar *remote = flatpak_decomposed_dup_remote (ref);
|
||||
|
||||
if (!flatpak_dir_remove_ref (self, remote, ref, cancellable, error))
|
||||
if (!flatpak_dir_remove_ref (self, remote, flatpak_decomposed_get_ref (ref), cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2048,7 +2048,7 @@ flatpak_installation_update_full (FlatpakInstallation *self,
|
||||
(flags & FLATPAK_UPDATE_FLAGS_NO_DEPLOY) != 0,
|
||||
(flags & FLATPAK_UPDATE_FLAGS_NO_STATIC_DELTAS) != 0,
|
||||
FALSE, FALSE, FALSE, state,
|
||||
flatpak_decomposed_get_ref (ref), target_commit,
|
||||
ref, target_commit,
|
||||
(const char **) subpaths, NULL, NULL, NULL, NULL,
|
||||
progress, cancellable, error))
|
||||
return NULL;
|
||||
@@ -2212,7 +2212,7 @@ flatpak_installation_uninstall_full (FlatpakInstallation *self,
|
||||
if (!flatpak_dir_ensure_repo (dir_clone, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!flatpak_dir_uninstall (dir_clone, flatpak_decomposed_get_ref (ref), FLATPAK_HELPER_UNINSTALL_FLAGS_NONE,
|
||||
if (!flatpak_dir_uninstall (dir_clone, ref, FLATPAK_HELPER_UNINSTALL_FLAGS_NONE,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
|
||||
@@ -4330,7 +4330,7 @@ _run_op_kind (FlatpakTransaction *self,
|
||||
priv->max_op >= APP_UPDATE,
|
||||
priv->max_op == APP_INSTALL || priv->max_op == RUNTIME_INSTALL,
|
||||
remote_state,
|
||||
flatpak_decomposed_get_ref (op->ref),
|
||||
op->ref,
|
||||
op->resolved_commit,
|
||||
(const char **) op->subpaths,
|
||||
(const char **) op->previous_ids,
|
||||
@@ -4401,7 +4401,7 @@ _run_op_kind (FlatpakTransaction *self,
|
||||
|
||||
emit_new_op (self, op, progress);
|
||||
|
||||
res = flatpak_dir_uninstall (priv->dir, flatpak_decomposed_get_ref (op->ref), flags,
|
||||
res = flatpak_dir_uninstall (priv->dir, op->ref, flags,
|
||||
cancellable, error);
|
||||
|
||||
flatpak_transaction_progress_done (progress);
|
||||
|
||||
@@ -925,6 +925,7 @@ handle_uninstall (FlatpakSystemHelper *object,
|
||||
{
|
||||
g_autoptr(FlatpakDir) system = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(FlatpakDecomposed) ref = NULL;
|
||||
|
||||
g_debug ("Uninstall %u %s %s", arg_flags, arg_ref, arg_installation);
|
||||
|
||||
@@ -935,6 +936,13 @@ handle_uninstall (FlatpakSystemHelper *object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ref = flatpak_decomposed_new_from_ref (arg_ref, &error);
|
||||
if (ref == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_UNINSTALL_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -948,7 +956,7 @@ handle_uninstall (FlatpakSystemHelper *object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!flatpak_dir_uninstall (system, arg_ref, arg_flags, NULL, &error))
|
||||
if (!flatpak_dir_uninstall (system, ref, arg_flags, NULL, &error))
|
||||
{
|
||||
flatpak_invocation_return_error (invocation, error, "Error uninstalling");
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user