diff options
author | Alexander Larsson <alexl@redhat.com> | 2020-06-30 14:43:15 +0200 |
---|---|---|
committer | Alexander Larsson <alexander.larsson@gmail.com> | 2020-06-30 16:13:51 +0200 |
commit | b283abe4917a652c041352b96fc2dfd45a1aee4d (patch) | |
tree | 27e8c97da9adb03bc6562dc7e952ae930d1448d2 | |
parent | 012f6de1f87b0674efb77ac8f764b3fa8fd7f7f8 (diff) | |
download | flatpak-b283abe4917a652c041352b96fc2dfd45a1aee4d.tar.gz |
transaction: Don't fail if install returns ALREADY_INSTALLED
We already verify that the ref is not installed on add_ref(), so we
did check for "user error". If the transaction either raced with some
other process, or the install from the install-authentitcator signal
that should not be treated as an error.
-rw-r--r-- | common/flatpak-transaction.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/common/flatpak-transaction.c b/common/flatpak-transaction.c index db9317e7..a61211a7 100644 --- a/common/flatpak-transaction.c +++ b/common/flatpak-transaction.c @@ -3832,12 +3832,14 @@ _run_op_kind (FlatpakTransaction *self, if (op->kind == FLATPAK_TRANSACTION_OPERATION_INSTALL) { g_autoptr(FlatpakTransactionProgress) progress = flatpak_transaction_progress_new (); + FlatpakTransactionResult result_details = 0; + g_autoptr(GError) local_error = NULL; emit_new_op (self, op, progress); g_assert (op->resolved_commit != NULL); /* We resolved this before */ - if (op->resolved_metakey && !flatpak_check_required_version (op->ref, op->resolved_metakey, error)) + if (op->resolved_metakey && !flatpak_check_required_version (op->ref, op->resolved_metakey, &local_error)) res = FALSE; else res = flatpak_dir_install (priv->dir, @@ -3853,12 +3855,27 @@ _run_op_kind (FlatpakTransaction *self, op->resolved_metadata, op->resolved_token, progress->progress_obj, - cancellable, error); + cancellable, &local_error); flatpak_transaction_progress_done (progress); + + /* Handle noop-installs (maybe we raced, or this was installed in install-authenticator) + * We do initial checks and fail with already installed in add_ref() for other cases. */ + if (!res && g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_ALREADY_INSTALLED)) + { + res = TRUE; + g_clear_error (&local_error); + + result_details |= FLATPAK_TRANSACTION_RESULT_NO_CHANGE; + } + else if (!res) + { + g_propagate_error (error, g_steal_pointer (&local_error)); + } + if (res) { - emit_op_done (self, op, 0); + emit_op_done (self, op, result_details); /* Normally we don't need to prune after install, because it makes no old objects stale. However if we reinstall, that is not true. */ |