[gnome-software: 15/25] gs-plugin-job-refine: Don’t recursive if refine flags are empty




commit d9db49c56baf3cfef36e5627a9eccd272bf8716a
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Feb 25 12:59:10 2022 +0000

    gs-plugin-job-refine: Don’t recursive if refine flags are empty
    
    The refine job recurses into related components of the components it’s
    been asked to refine, also refining them. For example, addons and
    runtimes of the apps it’s refining.
    
    To avoid infinite recursion, these recursive refines are done with
    various flags disabled. If those are the only flags in the set of
    `GsPluginRefineFlags`, though, the recursive refine operations will be
    no-ops.
    
    Might as well not do the recursion in those cases.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1658

 lib/gs-plugin-job-refine.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-plugin-job-refine.c b/lib/gs-plugin-job-refine.c
index 1bdc211d6..9e5bf7ca6 100644
--- a/lib/gs-plugin-job-refine.c
+++ b/lib/gs-plugin-job-refine.c
@@ -288,7 +288,8 @@ run_refine_internal (GsPluginJobRefine    *self,
                                gs_app_list_add (addons_list, addon);
                        }
                }
-               if (gs_app_list_length (addons_list) > 0) {
+
+               if (gs_app_list_length (addons_list) > 0 && addons_flags != 0) {
                        if (!run_refine_internal (self, plugin_loader,
                                                  addons_list, addons_flags,
                                                  cancellable, error)) {
@@ -302,6 +303,8 @@ run_refine_internal (GsPluginJobRefine    *self,
                g_autoptr(GsAppList) runtimes_list = gs_app_list_new ();
                GsPluginRefineFlags runtimes_flags = flags;
 
+               runtimes_flags &= ~GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME;
+
                for (guint i = 0; i < gs_app_list_length (list); i++) {
                        GsApp *app = gs_app_list_index (list, i);
                        GsApp *runtime = gs_app_get_runtime (app);
@@ -309,7 +312,8 @@ run_refine_internal (GsPluginJobRefine    *self,
                        if (runtime != NULL)
                                gs_app_list_add (runtimes_list, runtime);
                }
-               if (gs_app_list_length (runtimes_list) > 0) {
+
+               if (gs_app_list_length (runtimes_list) > 0 && runtimes_flags != 0) {
                        if (!run_refine_internal (self, plugin_loader,
                                                  runtimes_list, runtimes_flags,
                                                  cancellable, error)) {
@@ -336,7 +340,8 @@ run_refine_internal (GsPluginJobRefine    *self,
                                gs_app_list_add (related_list, app2);
                        }
                }
-               if (gs_app_list_length (related_list) > 0) {
+
+               if (gs_app_list_length (related_list) > 0 && related_flags != 0) {
                        if (!run_refine_internal (self, plugin_loader,
                                                  related_list, related_flags,
                                                  cancellable, error)) {


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