[gnome-software/uajain/flatpak-autoupdates-fix: 26/26] GsFlatpakTransaction: Correctly mark app's state if autoupdate is in progress



commit 5107deabd354c6bacfbddfbc82f9946af6fa5373
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Oct 4 07:07:16 2019 -0400

    GsFlatpakTransaction: Correctly mark app's state if autoupdate is in
    progress
    
    Autoupdating of apps is a two step process:
    Step 1. GS_PLUGIN_ACTION_DOWNLOAD (with --no-deploy)
    Step 2. GS_PLUGIN_ACTION_UPDATE (ideally with --no-pull)
    
    This distinction is lost when it comes to FlatpakTransaction.
    FlatpakTransaction considers both steps as
    FLATPAK_TRANSACTION_OPERATION_UPDATE and will set the GsApp's
    state as AS_APP_STATE_INSTALLED at the end of the transaction.
    
    Whereas in case of autoupdates, the correct state representation
    should also change w.r.t the plugin's current action such as;
    Completion of:
    Step 1: GS_PLUGIN_ACTION_DOWNLOAD → AS_APP_STATE_UPDATABLE_LIVE
    Step 2: GS_PLUGIN_ACTION_UPDATE   → AS_APP_STATE_INSTALLED
    
    Step 2. is basically deploying updates downloaded in Step 1.
    which cannot happen if the app's state is promoted to
    AS_APP_STATE_INSTALLED preemptively.
    
    https://gitlab.gnome.org/GNOME/gnome-software/issues/819#note_617828

 plugins/flatpak/gs-flatpak-transaction.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index ff0da9f1..0dfdb615 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -252,6 +252,7 @@ _transaction_operation_done (FlatpakTransaction *transaction,
                             const gchar *commit,
                             FlatpakTransactionResult details)
 {
+       GsFlatpakTransaction *self = GS_FLATPAK_TRANSACTION (transaction);
        /* invalidate */
        GsApp *app = _transaction_operation_get_app (operation);
        if (app == NULL) {
@@ -271,7 +272,10 @@ _transaction_operation_done (FlatpakTransaction *transaction,
                gs_app_set_update_version (app, NULL);
                /* force getting the new runtime */
                gs_app_remove_kudo (app, GS_APP_KUDO_SANDBOXED);
-               gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+               if (self->no_deploy) /* autoupdate in progress? */
+                       gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
+               else
+                       gs_app_set_state (app, AS_APP_STATE_INSTALLED);
                break;
        case FLATPAK_TRANSACTION_OPERATION_UNINSTALL:
                /* we don't actually know if this app is re-installable */


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