summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2023-03-02 20:12:36 +0000
committerAlexander Larsson <alexander.larsson@gmail.com>2023-03-30 14:54:18 +0200
commit9a2d0413f54b3fc6922a6c043bc8857a2f7fda6a (patch)
treeedeeabe7cd9debce008d0ee01eeea575d754ae20
parenta0f80cb32abd21dd3bc68224385dda0ed2411bfa (diff)
downloadflatpak-9a2d0413f54b3fc6922a6c043bc8857a2f7fda6a.tar.gz
app: Port transaction subclasses to use add_rebase_and_uninstall()
This fixes the possible situation where an eol-rebase app can be uninstalled and the new version not correctly installed (due to, for example, the install op failing due to a lack of disk space). Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #3991
-rw-r--r--app/flatpak-cli-transaction.c17
-rw-r--r--app/flatpak-quiet-transaction.c16
2 files changed, 2 insertions, 31 deletions
diff --git a/app/flatpak-cli-transaction.c b/app/flatpak-cli-transaction.c
index 829f44b2..6a19848f 100644
--- a/app/flatpak-cli-transaction.c
+++ b/app/flatpak-cli-transaction.c
@@ -988,7 +988,7 @@ end_of_lifed_with_rebase (FlatpakTransaction *transaction,
{
g_autoptr(GError) error = NULL;
- if (!flatpak_transaction_add_rebase (transaction, remote, rebased_to_ref, NULL, previous_ids, &error))
+ if (!flatpak_transaction_add_rebase_and_uninstall (transaction, remote, rebased_to_ref, ref_str, NULL, previous_ids, &error))
{
g_propagate_prefixed_error (&self->first_operation_error,
g_error_copy (error),
@@ -997,21 +997,6 @@ end_of_lifed_with_rebase (FlatpakTransaction *transaction,
return FALSE;
}
- if (!flatpak_transaction_add_uninstall (transaction, ref_str, &error))
- {
- /* NOT_INSTALLED error is expected in case the op that triggered this was install not update */
- if (g_error_matches (error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_INSTALLED))
- g_clear_error (&error);
- else
- {
- g_propagate_prefixed_error (&self->first_operation_error,
- g_error_copy (error),
- _("Failed to uninstall %s for rebase to %s: "),
- name, rebased_to_ref);
- return FALSE;
- }
- }
-
return TRUE; /* skip install/update op of end-of-life ref */
}
else /* IGNORE or NO_REBASE */
diff --git a/app/flatpak-quiet-transaction.c b/app/flatpak-quiet-transaction.c
index 0a2c5ca7..137c9baf 100644
--- a/app/flatpak-quiet-transaction.c
+++ b/app/flatpak-quiet-transaction.c
@@ -246,7 +246,7 @@ end_of_lifed_with_rebase (FlatpakTransaction *transaction,
g_print (_("Updating to rebased version\n"));
- if (!flatpak_transaction_add_rebase (transaction, remote, rebased_to_ref, NULL, previous_ids, &error))
+ if (!flatpak_transaction_add_rebase_and_uninstall (transaction, remote, rebased_to_ref, ref, NULL, previous_ids, &error))
{
g_printerr (_("Failed to rebase %s to %s: %s\n"),
flatpak_ref_get_name (rref), rebased_to_ref, error->message);
@@ -254,20 +254,6 @@ end_of_lifed_with_rebase (FlatpakTransaction *transaction,
return FALSE;
}
- if (!flatpak_transaction_add_uninstall (transaction, ref, &error))
- {
- /* NOT_INSTALLED error is expected in case the op that triggered this was install not update */
- if (g_error_matches (error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_INSTALLED))
- g_clear_error (&error);
- else
- {
- g_printerr (_("Failed to uninstall %s for rebase to %s: %s\n"),
- flatpak_ref_get_name (rref), rebased_to_ref, error->message);
- self->got_error = TRUE;
- return FALSE;
- }
- }
-
return TRUE;
}