[gnome-software/gnome-3-36] flatpak: Operate on a copy of the FlatpakInstallation
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-36] flatpak: Operate on a copy of the FlatpakInstallation
- Date: Fri, 22 May 2020 14:12:38 +0000 (UTC)
commit 8a847bdf7da1d121e8bf5a0af3252494b6b28960
Author: Philip Withnall <withnall endlessm com>
Date: Wed Apr 22 12:33:39 2020 +0100
flatpak: Operate on a copy of the FlatpakInstallation
This means that global state changes, such as to the `no-interaction` flag
of the `FlatpakInstallation`, don’t escape outside the context of the
transaction currently being run.
This is a follow up to !283, using a suggestion by Matthias Clasen.
Signed-off-by: Philip Withnall <withnall endlessm com>
plugins/flatpak/gs-plugin-flatpak.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index faf52c96..e500f1f7 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -445,16 +445,27 @@ _build_transaction (GsPlugin *plugin, GsFlatpak *flatpak,
GCancellable *cancellable, GError **error)
{
FlatpakInstallation *installation;
+ g_autoptr(GFile) installation_path = NULL;
+ g_autoptr(FlatpakInstallation) installation_clone = NULL;
g_autoptr(FlatpakTransaction) transaction = NULL;
installation = gs_flatpak_get_installation (flatpak);
+ /* Operate on a copy of the installation so we can set the interactive
+ * flag for the duration of this transaction. */
+ installation_path = flatpak_installation_get_path (installation);
+ installation_clone = flatpak_installation_new_for_path (installation_path,
+ flatpak_installation_get_is_user
(installation),
+ cancellable, error);
+ if (installation_clone == NULL)
+ return NULL;
+
/* Let flatpak know if it is a background operation */
- if (!gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE))
- flatpak_installation_set_no_interaction (installation, TRUE);
+ flatpak_installation_set_no_interaction (installation_clone,
+ !gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
/* create transaction */
- transaction = gs_flatpak_transaction_new (installation, cancellable, error);
+ transaction = gs_flatpak_transaction_new (installation_clone, cancellable, error);
if (transaction == NULL) {
g_prefix_error (error, "failed to build transaction: ");
gs_flatpak_error_convert (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]