[gnome-software/uajain/set-no-pull-autoupdate] flatpak: Mark the transaction with --no-pull for autoupdating apps



commit b37e169c6a29daac701671116ccf20ec696d8315
Author: Umang Jain <umang endlessm com>
Date:   Fri Oct 4 12:40:15 2019 +0530

    flatpak: Mark the transaction with --no-pull for autoupdating apps
    
    Autoupdates code path is essentially a GS_PLUGIN_ACTION_DOWNLOAD
    followed by a GS_PLUGIN_ACTION_UPDATE action. The download action
    sets the --no-deploy flag on the transaction so that all the
    update gets downloaded to local cache but does not get deployed (yet).
    
    Hence, the upate action should primarily execute the deployment
    phase for the downloads fetched via GS_PLUGIN_ACTION_DOWNLOAD.
    Flatpak-cli equivalent is : flatpak update --no-pull
    
    It was discovered that this wasn't the case in gnome-software.
    Without the --no-pull flag in autoupdates case, GS_PLUGIN_ACTION_UPDATE
    will try to fetch/query the outstanding updates again.
    Hence, mark the transaction with --no-pull if we discover
    an autoupdate is in progress.
    
    The bug was noticed while investigating a larger problem in
    https://gitlab.gnome.org/GNOME/gnome-software/issues/819

 plugins/flatpak/gs-plugin-flatpak.c | 5 +++++
 plugins/flatpak/gs-self-test.c      | 1 +
 2 files changed, 6 insertions(+)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 228dedbc..a91a4c12 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -737,6 +737,7 @@ gs_plugin_flatpak_update (GsPlugin *plugin,
                          GError **error)
 {
        g_autoptr(FlatpakTransaction) transaction = NULL;
+       gboolean is_auto_update = !gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE);
 
        /* build and run transaction */
        transaction = _build_transaction (plugin, flatpak, cancellable, error);
@@ -745,6 +746,10 @@ gs_plugin_flatpak_update (GsPlugin *plugin,
                return FALSE;
        }
 
+       /* Update action on auto updates is essentially a deploy operation. */
+       if (is_auto_update)
+               flatpak_transaction_set_no_pull (transaction, TRUE);
+
        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;
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 6a1aa74f..5d3de7d2 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -1402,6 +1402,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        g_object_unref (plugin_job);
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPDATE,
                                         "app", app,
+                                        "interactive", TRUE,
                                         NULL);
        gs_plugin_loader_job_process_async (plugin_loader, plugin_job,
                                            NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]