Get all mirrors before deleting repo

1. Get ALL mirrors and not just the non-disabled ones.
2. Get them freshly before deleting the repo (in the very rare/should-not-happen
   case that they have changed since the ViewModel was created).

Follow-up to fdroid/fdroidclient!1499
This commit is contained in:
Thore Goebel
2025-02-11 22:26:49 +01:00
committed by Torsten Grote
parent 0fd81915e7
commit f61e9971ab

View File

@@ -61,7 +61,6 @@ class RepoDetailsViewModel(
}
private val repoId = initialRepo.repoId
private val repoMirrors = initialRepo.getMirrors()
private val repoManager = FDroidApp.getRepoManager(app)
private val appDao = DBHelper.getDb(app).getAppDao()
@@ -104,14 +103,13 @@ class RepoDetailsViewModel(
}
fun deleteRepository() {
val cache = DnsCache.get()
val mirrors = repoFlow.value?.getAllMirrors() ?: emptyList()
mirrors.forEach { cache.remove(it.url.host) }
viewModelScope.launch(Dispatchers.IO) {
repoManager.deleteRepository(repoId)
}
// clean up dns cache
val cache = DnsCache.get()
for (mirror in repoMirrors) {
cache.remove(mirror.url.host)
}
}
fun updateUsernameAndPassword(username: String, password: String) {