[gnome-software: 23/24] packagekit: Set task background status in task setup




commit 9d947454f3f79ca641235b9f92792632cd21bd54
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Apr 29 12:00:21 2022 +0100

    packagekit: Set task background status in task setup
    
    Rather than setting it separately. While `:background` and
    `:interactive` have different semantics, we currently always want to set
    them using the same conditions.
    
    This means `pk_client_set_background()` is now more consistently called
    before a `PkClient` is used; previously it was possible for a stale
    background value from the previous use of the `PkClient` to be reused
    incorrectly.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/packagekit/gs-packagekit-task.c   | 10 ++++++++++
 plugins/packagekit/gs-plugin-packagekit.c |  2 --
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/plugins/packagekit/gs-packagekit-task.c b/plugins/packagekit/gs-packagekit-task.c
index 6e352760d..05c64e863 100644
--- a/plugins/packagekit/gs-packagekit-task.c
+++ b/plugins/packagekit/gs-packagekit-task.c
@@ -229,7 +229,17 @@ gs_packagekit_task_setup (GsPackagekitTask *task,
        g_return_if_fail (GS_IS_PACKAGEKIT_TASK (task));
 
        priv->action = action;
+
+       /* The :interactive and :background properties have slightly different
+        * purposes:
+        *  - :interactive controls whether the task can create interactive
+        *    authentication (polkit) prompts
+        *  - :background controls the scheduling of the task relative to other
+        *    PackageKit tasks from this client and other clients
+        * However, we always want to set them both based on the same
+        * conditions. */
        pk_client_set_interactive (PK_CLIENT (task), interactive);
+       pk_client_set_background (PK_CLIENT (task), !interactive);
 }
 
 GsPluginAction
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 2d2a37d8c..ca630e60b 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -902,7 +902,6 @@ gs_plugin_packagekit_list_apps_async (GsPlugin              *plugin,
        gs_packagekit_helper_set_progress_app (helper, app_dl);
 
        g_mutex_lock (&self->task_mutex);
-       pk_client_set_background (PK_CLIENT (self->task), !interactive);
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (self->task), GS_PLUGIN_ACTION_UNKNOWN, interactive);
 
        if (gs_app_query_get_provides_files (query) != NULL) {
@@ -3755,7 +3754,6 @@ gs_plugin_packagekit_refresh_metadata_async (GsPlugin                     *plugi
        gs_packagekit_helper_set_progress_app (helper, app_dl);
 
        g_mutex_lock (&self->task_mutex_refresh);
-       pk_client_set_background (PK_CLIENT (self->task_refresh), !interactive);
        gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (self->task_refresh), GS_PLUGIN_ACTION_UNKNOWN, 
interactive);
        pk_client_set_cache_age (PK_CLIENT (self->task_refresh), cache_age_secs);
 


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