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



commit 0be84f149cc8c39b09e1737fb0838cb21158b843
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 | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-flatpak-transaction.c b/plugins/flatpak/gs-flatpak-transaction.c
index c477d70f..57b7a05c 100644
--- a/plugins/flatpak/gs-flatpak-transaction.c
+++ b/plugins/flatpak/gs-flatpak-transaction.c
@@ -263,6 +263,9 @@ _transaction_operation_done (FlatpakTransaction *transaction,
                             const gchar *commit,
                             FlatpakTransactionResult details)
 {
+#if !FLATPAK_CHECK_VERSION(1,5,1)
+       GsFlatpakTransaction *self = GS_FLATPAK_TRANSACTION (transaction);
+#endif
        /* invalidate */
        GsApp *app = _transaction_operation_get_app (operation);
        if (app == NULL) {
@@ -282,7 +285,15 @@ _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);
+                /* downloaded, but not yet installed */
+#if !FLATPAK_CHECK_VERSION(1,5,1)
+               if (self->no_deploy)
+#else
+               if (flatpak_transaction_get_no_deploy (transaction))
+#endif
+                       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]