[gnome-software/gnome-3-30] flatpak: Construct one big transaction for all updates
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-30] flatpak: Construct one big transaction for all updates
- Date: Fri, 30 Nov 2018 16:04:01 +0000 (UTC)
commit e6e03ce78c8b05354998ffcbf5e033f321e0d6bc
Author: Kalev Lember <klember redhat com>
Date: Thu Nov 15 01:27:14 2018 +0100
flatpak: Construct one big transaction for all updates
Let's give this another try. The reason we reverted this the first time
was that it regressed error reporting: as the plugin loader no longer
drives app updating, it didn't know how to map errors that occur to apps
and then we got errors such as 'Unable to update "(null)"' in the UI.
However, this time around we have a mechanism for passing app IDs from
the plugins up to the plugin loader and this commit is updated to make
use of that.
---
Instad of updating apps one by one, construct one big transaction that
includes everything we need to update.
This makes state keeping in gnome-software easier, as when we
simplistically walk the update list and update one by one, sometimes
updates depend on each other (app requires runtime) and we may end up in
a case where the update is already installed.
Furthermore, alex is saying that the CLI also makes one big transaction
and doing so is more efficient as it avoids prunes and triggers between
each update.
This reverts commit eee60ee8905b73bb874a4900a261ad1b54f958d8.
plugins/flatpak/gs-flatpak-transaction.c | 3 ++
plugins/flatpak/gs-plugin-flatpak.c | 62 +++++++++++++++++++++-----------
2 files changed, 45 insertions(+), 20 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index c6735515..606187d2 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -292,6 +292,7 @@ _transaction_operation_error (FlatpakTransaction *transaction,
{
GsFlatpakTransaction *self = GS_FLATPAK_TRANSACTION (transaction);
FlatpakTransactionOperationType operation_type = flatpak_transaction_operation_get_operation_type
(operation);
+ GsApp *app = _transaction_operation_get_app (operation);
const gchar *ref = flatpak_transaction_operation_get_ref (operation);
if (g_error_matches (error, FLATPAK_ERROR, FLATPAK_ERROR_SKIPPED)) {
@@ -313,6 +314,8 @@ _transaction_operation_error (FlatpakTransaction *transaction,
if (self->first_operation_error == NULL) {
g_propagate_error (&self->first_operation_error,
g_error_copy (error));
+ if (app != NULL)
+ gs_utils_error_add_app_id (&self->first_operation_error, app);
}
return FALSE; /* stop */
}
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index ed1a5679..5a4f89cc 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -687,17 +687,22 @@ gs_plugin_app_install (GsPlugin *plugin,
}
gboolean
-gs_plugin_update_app (GsPlugin *plugin,
- GsApp *app,
- GCancellable *cancellable,
- GError **error)
+gs_plugin_update (GsPlugin *plugin,
+ GsAppList *list,
+ GCancellable *cancellable,
+ GError **error)
{
GsFlatpak *flatpak;
g_autoptr(FlatpakTransaction) transaction = NULL;
- g_autofree gchar *ref = NULL;
+ g_autoptr(GsAppList) list_tmp = gs_app_list_new ();
/* not supported */
- flatpak = gs_plugin_flatpak_get_handler (plugin, app);
+ for (guint i = 0; i < gs_app_list_length (list); i++) {
+ GsApp *app = gs_app_list_index (list, i);
+ flatpak = gs_plugin_flatpak_get_handler (plugin, app);
+ if (flatpak != NULL)
+ gs_app_list_add (list_tmp, app);
+ }
if (flatpak == NULL)
return TRUE;
@@ -707,19 +712,30 @@ gs_plugin_update_app (GsPlugin *plugin,
gs_flatpak_error_convert (error);
return FALSE;
}
- ref = gs_flatpak_app_get_ref_display (app);
- if (!flatpak_transaction_add_update (transaction, ref, NULL, NULL, error)) {
- g_prefix_error (error, "failed to add update ref %s: ", ref);
- gs_flatpak_error_convert (error);
- return FALSE;
+
+ for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
+ GsApp *app = gs_app_list_index (list_tmp, i);
+ g_autofree gchar *ref = NULL;
+
+ ref = gs_flatpak_app_get_ref_display (app);
+ if (!flatpak_transaction_add_update (transaction, ref, NULL, NULL, error)) {
+ g_prefix_error (error, "failed to add update ref %s: ", ref);
+ gs_flatpak_error_convert (error);
+ return FALSE;
+ }
}
/* run transaction */
- gs_app_set_state (app, AS_APP_STATE_INSTALLING);
+ for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
+ GsApp *app = gs_app_list_index (list_tmp, i);
+ gs_app_set_state (app, AS_APP_STATE_INSTALLING);
+ }
if (!gs_flatpak_transaction_run (transaction, cancellable, error)) {
- g_prefix_error (error, "failed to run transaction for %s: ", ref);
+ for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
+ GsApp *app = gs_app_list_index (list_tmp, i);
+ gs_app_set_state_recover (app);
+ }
gs_flatpak_error_convert (error);
- gs_app_set_state_recover (app);
return FALSE;
}
gs_plugin_updates_changed (plugin);
@@ -729,12 +745,18 @@ gs_plugin_update_app (GsPlugin *plugin,
gs_flatpak_error_convert (error);
return FALSE;
}
- if (!gs_flatpak_refine_app (flatpak, app,
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME,
- cancellable, error)) {
- g_prefix_error (error, "failed to run refine for %s: ", ref);
- gs_flatpak_error_convert (error);
- return FALSE;
+ for (guint i = 0; i < gs_app_list_length (list_tmp); i++) {
+ GsApp *app = gs_app_list_index (list_tmp, i);
+ g_autofree gchar *ref = NULL;
+
+ ref = gs_flatpak_app_get_ref_display (app);
+ if (!gs_flatpak_refine_app (flatpak, app,
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME,
+ cancellable, error)) {
+ g_prefix_error (error, "failed to run refine for %s: ", ref);
+ gs_flatpak_error_convert (error);
+ return FALSE;
+ }
}
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]