[gnome-software: 69/72] gs-plugin-job-refine: Allow skipping filtering of refine results




commit 2cb9cc156171cdc9bbd3a713a110a1f465d1b481
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Dec 8 11:03:11 2021 +0000

    gs-plugin-job-refine: Allow skipping filtering of refine results
    
    When used internally, we don’t want to filter the results of a refine
    operation, as those results might need further processing by whatever
    operation triggered the refine.
    
    We only really want to filter refine results when the refine is being
    called explicitly by the UI.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin-job-refine.c | 13 ++++++++++++-
 lib/gs-plugin-loader.c     | 12 ++++++------
 lib/gs-plugin-types.h      |  5 ++++-
 3 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/lib/gs-plugin-job-refine.c b/lib/gs-plugin-job-refine.c
index 21691aabb..bd4cd13b9 100644
--- a/lib/gs-plugin-job-refine.c
+++ b/lib/gs-plugin-job-refine.c
@@ -450,7 +450,18 @@ gs_plugin_job_refine_run_async (GsPluginJob         *job,
                g_debug ("no refine flags set for transaction");
        }
 
-       gs_app_list_filter (result_list, app_is_valid_filter, self);
+       /* Internal calls to #GsPluginJobRefine may want to do their own
+        * filtering, typically if the refine is being done as part of another
+        * plugin job. If so, only filter to remove wildcards. Wildcards should
+        * always be removed, as they should have been resolved as part of the
+        * refine; any remaining wildcards will never be resolved.
+        *
+        * If the flag is not specified, filter by a variety of indicators of
+        * what a ‘valid’ app is. */
+       if (self->flags & GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING)
+               gs_app_list_filter (result_list, app_is_non_wildcard, NULL);
+       else
+               gs_app_list_filter (result_list, app_is_valid_filter, self);
 
        /* show elapsed time */
        job_debug = gs_plugin_job_to_string (job);
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6d2c7a732..cd9c7e4aa 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1562,7 +1562,7 @@ load_install_queue (GsPluginLoader *plugin_loader, GError **error)
                g_autoptr(GAsyncResult) refine_result = NULL;
                g_autoptr(GsAppList) new_list = NULL;
 
-               refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID);
+               refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID | 
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
                gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                                    NULL,
                                                    async_result_cb,
@@ -3293,7 +3293,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
 
                g_debug ("running filter flags with early refine");
 
-               refine_job = gs_plugin_job_refine_new (list, filter_flags);
+               refine_job = gs_plugin_job_refine_new (list, filter_flags | 
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
                gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                                    cancellable,
                                                    async_result_cb,
@@ -3352,7 +3352,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
                g_autoptr(GAsyncResult) refine_result = NULL;
                g_autoptr(GsAppList) new_list = NULL;
 
-               refine_job = gs_plugin_job_refine_new (list, gs_plugin_job_get_refine_flags 
(helper->plugin_job));
+               refine_job = gs_plugin_job_refine_new (list, gs_plugin_job_get_refine_flags 
(helper->plugin_job) | GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
                gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                                    cancellable,
                                                    async_result_cb,
@@ -3398,7 +3398,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
                        }
                }
 
-               refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON);
+               refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON | 
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
                gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                                    cancellable,
                                                    async_result_cb,
@@ -3793,7 +3793,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
 
                        /* Refine the list of wildcard popular apps and return
                         * to the caller. */
-                       refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID);
+                       refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID | 
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
                        gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                                            cancellable,
                                                            callback, user_data);
@@ -4052,7 +4052,7 @@ gs_plugin_loader_app_create_async (GsPluginLoader *plugin_loader,
        gs_app_list_add (list, app);
 
        /* Refine the wildcard app. */
-       refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID);
+       refine_job = gs_plugin_job_refine_new (list, GS_PLUGIN_REFINE_FLAGS_REQUIRE_ID | 
GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING);
        gs_plugin_loader_job_process_async (plugin_loader, refine_job,
                                            cancellable,
                                            app_create_cb,
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 91548cd21..e938ebf23 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -114,6 +114,9 @@ typedef enum {
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE:         Require the provenance
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS:            Require user-reviews
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS:     Require user-ratings
+ * @GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING:          Normally the results of a refine are
+ *     filtered to remove non-valid apps; if this flag is set, that won’t happen.
+ *     This is intended to be used by internal #GsPluginLoader code. (Since: 42)
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON:               Require the icon to be loaded
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS:                Require the needed permissions
  * @GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME:    Require the origin hostname
@@ -152,7 +155,7 @@ typedef enum {
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE       = 1 << 17,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS          = 1 << 18,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS   = 1 << 19,
-       /* 1 << 20 is currently unused; was previously REQUIRE_KEY_COLORS */
+       GS_PLUGIN_REFINE_FLAGS_DISABLE_FILTERING        = 1 << 20,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON             = 1 << 21,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS      = 1 << 22,
        GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME  = 1 << 23,


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