Skip to content

Commit

Permalink
app: Port transaction subclasses to use add_rebase_and_uninstall()
Browse files Browse the repository at this point in the history
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 <[email protected]>

Fixes: #3991
  • Loading branch information
pwithnall authored and alexlarsson committed Mar 30, 2023
1 parent a0f80cb commit 9a2d041
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
17 changes: 1 addition & 16 deletions app/flatpak-cli-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 */
Expand Down
16 changes: 1 addition & 15 deletions app/flatpak-quiet-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,14 @@ 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);
self->got_error = TRUE;
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;
}

Expand Down

0 comments on commit 9a2d041

Please sign in to comment.