mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 19:34:35 -05:00
Add mutex to "updateExtensionDatabase" (#829)
If called in quick succession it is possible that duplicated extensions get inserted to the database, because it has not yet been updated by the first call
This commit is contained in:
@@ -8,6 +8,8 @@ package suwayomi.tachidesk.manga.impl.extension
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import eu.kanade.tachiyomi.source.local.LocalSource
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
@@ -86,7 +88,10 @@ object ExtensionsList {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateExtensionDatabase(foundExtensions: List<OnlineExtension>) {
|
||||
private val updateExtensionDatabaseMutex = Mutex()
|
||||
|
||||
private suspend fun updateExtensionDatabase(foundExtensions: List<OnlineExtension>) {
|
||||
updateExtensionDatabaseMutex.withLock {
|
||||
transaction {
|
||||
val uniqueExtensions =
|
||||
foundExtensions.groupBy { it.pkgName }.mapValues {
|
||||
@@ -200,6 +205,7 @@ object ExtensionsList {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.repoUrlReplace(): String {
|
||||
return if (contains("github")) {
|
||||
|
||||
Reference in New Issue
Block a user