[gnome-software: 5/25] gs-odrs-provider: Fix incorrect early returns when refining apps




commit 3ad1cf5106f21a85bbeda6c96fc627de9ccdb4aa
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Feb 23 14:36:09 2022 +0000

    gs-odrs-provider: Fix incorrect early returns when refining apps
    
    If the app already had review data, but no ratings data, the code to
    fetch the reviews would incorrectly return before fetching the ratings.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-odrs-provider.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-odrs-provider.c b/lib/gs-odrs-provider.c
index a90aeed87..18ab6886b 100644
--- a/lib/gs-odrs-provider.c
+++ b/lib/gs-odrs-provider.c
@@ -1377,13 +1377,11 @@ refine_app (GsOdrsProvider             *self,
                return TRUE;
 
        /* add reviews if possible */
-       if (flags & GS_ODRS_PROVIDER_REFINE_FLAGS_GET_REVIEWS) {
+       if ((flags & GS_ODRS_PROVIDER_REFINE_FLAGS_GET_REVIEWS) &&
+           gs_app_get_reviews (app)->len == 0) {
                AsReview *review;
                g_autoptr(GPtrArray) reviews = NULL;
 
-               if (gs_app_get_reviews (app)->len > 0)
-                       return TRUE;
-
                /* get from server */
                reviews = gs_odrs_provider_fetch_for_app (self, app, cancellable, error);
                if (reviews == NULL)
@@ -1412,9 +1410,8 @@ refine_app (GsOdrsProvider             *self,
        }
 
        /* add ratings if possible */
-       if (flags & GS_ODRS_PROVIDER_REFINE_FLAGS_GET_RATINGS) {
-               if (gs_app_get_review_ratings (app) != NULL)
-                       return TRUE;
+       if ((flags & GS_ODRS_PROVIDER_REFINE_FLAGS_GET_RATINGS) &&
+           gs_app_get_review_ratings (app) == NULL) {
                if (!gs_odrs_provider_refine_ratings (self, app, cancellable, error))
                        return FALSE;
        }


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