mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-02 20:54:19 -04:00
[db] New repos now get lower weight than older ones
so they do not override the information from older repos anymore. This is especially an issue for the official repo which historically had the lowest priority while it should have the highest.
This commit is contained in:
@@ -354,7 +354,7 @@ internal interface AppDaoInt : AppDao {
|
||||
JOIN ${RepositoryPreferences.TABLE} AS pref USING (repoId)
|
||||
LEFT JOIN ${HighestVersion.TABLE} AS version USING (repoId, packageName)
|
||||
LEFT JOIN ${LocalizedIcon.TABLE} AS icon USING (repoId, packageName)
|
||||
LEFT JOIN AppPrefs USING (packageName)
|
||||
LEFT JOIN ${AppPrefs.TABLE} USING (packageName)
|
||||
WHERE pref.enabled = 1 AND COALESCE(preferredRepoId, repoId) = repoId
|
||||
GROUP BY packageName HAVING MAX(pref.weight)
|
||||
ORDER BY localizedName IS NULL ASC, icon.packageName IS NULL ASC,
|
||||
|
||||
@@ -151,10 +151,10 @@ internal interface RepositoryDaoInt : RepositoryDao {
|
||||
certificate = newRepository.certificate,
|
||||
)
|
||||
val repoId = insertOrReplace(repo)
|
||||
val currentMaxWeight = getMaxRepositoryWeight()
|
||||
val currentMinWeight = getMinRepositoryWeight()
|
||||
val repositoryPreferences = RepositoryPreferences(
|
||||
repoId = repoId,
|
||||
weight = currentMaxWeight + 1,
|
||||
weight = currentMinWeight - 2,
|
||||
lastUpdated = null,
|
||||
username = newRepository.username,
|
||||
password = newRepository.password,
|
||||
@@ -181,10 +181,10 @@ internal interface RepositoryDaoInt : RepositoryDao {
|
||||
certificate = null,
|
||||
)
|
||||
val repoId = insertOrReplace(repo)
|
||||
val currentMaxWeight = getMaxRepositoryWeight()
|
||||
val currentMinWeight = getMinRepositoryWeight()
|
||||
val repositoryPreferences = RepositoryPreferences(
|
||||
repoId = repoId,
|
||||
weight = currentMaxWeight + 1,
|
||||
weight = currentMinWeight - 2,
|
||||
lastUpdated = null,
|
||||
username = username,
|
||||
password = password,
|
||||
@@ -197,15 +197,15 @@ internal interface RepositoryDaoInt : RepositoryDao {
|
||||
@VisibleForTesting
|
||||
fun insertOrReplace(repository: RepoV2, version: Long = 0): Long {
|
||||
val repoId = insertOrReplace(repository.toCoreRepository(version = version))
|
||||
val currentMaxWeight = getMaxRepositoryWeight()
|
||||
val repositoryPreferences = RepositoryPreferences(repoId, currentMaxWeight + 1)
|
||||
val currentMinWeight = getMinRepositoryWeight()
|
||||
val repositoryPreferences = RepositoryPreferences(repoId, currentMinWeight - 2)
|
||||
insert(repositoryPreferences)
|
||||
insertRepoTables(repoId, repository)
|
||||
return repoId
|
||||
}
|
||||
|
||||
@Query("SELECT MAX(weight) FROM ${RepositoryPreferences.TABLE}")
|
||||
fun getMaxRepositoryWeight(): Int
|
||||
@Query("SELECT COALESCE(MIN(weight), ${Int.MAX_VALUE}) FROM ${RepositoryPreferences.TABLE}")
|
||||
fun getMinRepositoryWeight(): Int
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM ${CoreRepository.TABLE} WHERE repoId = :repoId")
|
||||
|
||||
Reference in New Issue
Block a user