summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2018-04-19 11:47:25 +0100
committerRichard Hughes <richard@hughsie.com>2018-04-19 11:47:28 +0100
commit56b46cf0cda07ae081411e64662babb6c0e1d42a (patch)
tree09d76d05907020480be7e9e01c0025fb6de7c276
parent4989c789bb5399f31ac4c902a0356abc09e2d89f (diff)
downloadappstream-glib-56b46cf0cda07ae081411e64662babb6c0e1d42a.tar.gz
trivial: Prefer the timestamp if set when ordering releases
This means we always order from newest to oldest, even when upstream uses funky versions like '5269+/dag'.
-rw-r--r--libappstream-glib/as-release.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c
index b74a243..785bea4 100644
--- a/libappstream-glib/as-release.c
+++ b/libappstream-glib/as-release.c
@@ -238,16 +238,17 @@ as_release_vercmp (AsRelease *rel1, AsRelease *rel2)
AsReleasePrivate *priv2 = GET_PRIVATE (rel2);
gint val;
- /* prefer the version strings */
- val = as_utils_vercmp (priv2->version, priv1->version);
- if (val != G_MAXINT)
- return val;
-
- /* fall back to the timestamp */
+ /* prefer the timestamp */
if (priv1->timestamp > priv2->timestamp)
return -1;
if (priv1->timestamp < priv2->timestamp)
return 1;
+
+ /* fall back to the version strings */
+ val = as_utils_vercmp (priv2->version, priv1->version);
+ if (val != G_MAXINT)
+ return val;
+
return 0;
}