From aebf7efc10c7c2f5d808b9fedb82cf5aa2ff4a04 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 14 Feb 2019 10:39:00 +0100 Subject: [PATCH] add canonical URL as first item in ordered mirror list This makes it display nicely in RepoDetails, and is natural, since it is the canonical URL. This also maintains the order as received from the mirror entries in the index file. --- app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java index 0a110be84..8d57e185e 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java @@ -65,9 +65,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.TreeSet; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -294,11 +294,10 @@ public class IndexV1Updater extends IndexUpdater { repo.icon = getStringRepoValue(repoMap, "icon"); repo.description = getStringRepoValue(repoMap, "description"); - // ensure the canonical URL is included in the "mirrors" list - List mirrorsList = getStringListRepoValue(repoMap, "mirrors"); - HashSet mirrors = new HashSet<>(mirrorsList.size() + 1); - mirrors.addAll(mirrorsList); + // ensure the canonical URL is included in the "mirrors" list as the first entry + TreeSet mirrors = new TreeSet<>(); mirrors.add(repo.address); + mirrors.addAll(getStringListRepoValue(repoMap, "mirrors")); repo.mirrors = mirrors.toArray(new String[mirrors.size()]); // below are optional, can be default value