[gnome-software: 1/3] gs-os-update-page: Simplify is_downgrade check




commit a57d47b83a1142f51478ddddde206285d1eb7566
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date:   Wed Dec 1 18:01:09 2021 +0100

    gs-os-update-page: Simplify is_downgrade check
    
    appstream is a dependency and can do the work for us. This reduces
    code duplication accross projects and simplifies the check.

 src/gs-os-update-page.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
---
diff --git a/src/gs-os-update-page.c b/src/gs-os-update-page.c
index 5cbe0120a..ed63163e5 100644
--- a/src/gs-os-update-page.c
+++ b/src/gs-os-update-page.c
@@ -175,32 +175,11 @@ is_downgrade (const gchar *evr1,
               const gchar *evr2)
 {
        gint rc;
-       g_autofree gchar *epoch1 = NULL;
-       g_autofree gchar *epoch2 = NULL;
-       g_autofree gchar *version1 = NULL;
-       g_autofree gchar *version2 = NULL;
-       g_autofree gchar *release1 = NULL;
-       g_autofree gchar *release2 = NULL;
 
        if (evr1 == NULL || evr2 == NULL)
                return FALSE;
 
-       /* split into epoch-version-release */
-       if (!gs_utils_parse_evr (evr1, &epoch1, &version1, &release1))
-               return FALSE;
-       if (!gs_utils_parse_evr (evr2, &epoch2, &version2, &release2))
-               return FALSE;
-
-       /* ignore epoch here as it's a way to make downgrades happen and not
-        * part of the semantic version */
-
-       /* check version */
-       rc = as_vercmp_simple (version1, version2);
-       if (rc != 0)
-               return rc > 0;
-
-       /* check release */
-       rc = as_vercmp_simple (release1, release2);
+       rc = as_vercmp (evr1, evr2, AS_VERCMP_FLAG_IGNORE_EPOCH);
        if (rc != 0)
                return rc > 0;
 


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