[db] don't allow initial repos from fixtures to provide weight

The client was already auto-incrementing their weight anyway. But it leaked our internal weight handling into the library consumer which can cause issues like when me are making changes to how we handles repo weights as we are doing now.
This commit is contained in:
Torsten Grote
2023-11-03 11:30:44 -03:00
parent b993da8db8
commit 51a4bcec58
3 changed files with 5 additions and 4 deletions

View File

@@ -393,7 +393,8 @@ public data class InitialRepository @JvmOverloads constructor(
val certificate: String,
val version: Long,
val enabled: Boolean,
val weight: Int,
@Deprecated("This is automatically assigned now and can be safely removed.")
val weight: Int = 0, // still used for testing, could be made internal or tests migrate away
) {
init {
validateCertificate(certificate)

View File

@@ -127,9 +127,10 @@ internal interface RepositoryDaoInt : RepositoryDao {
certificate = initialRepo.certificate,
)
val repoId = insertOrReplace(repo)
val currentMinWeight = getMinRepositoryWeight()
val repositoryPreferences = RepositoryPreferences(
repoId = repoId,
weight = initialRepo.weight,
weight = currentMinWeight - 2,
lastUpdated = null,
enabled = initialRepo.enabled,
)