mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
Remove caching of extensions for gql mutation (#806)
The client should use the extension query to get "cached" extensions and the mutation to update the extensions
This commit is contained in:
@@ -35,10 +35,6 @@ object ExtensionsList {
|
|||||||
|
|
||||||
suspend fun fetchExtensions() {
|
suspend fun fetchExtensions() {
|
||||||
// update if 60 seconds has passed or requested offline and database is empty
|
// update if 60 seconds has passed or requested offline and database is empty
|
||||||
if (lastUpdateCheck + 60.seconds.inWholeMilliseconds < System.currentTimeMillis()) {
|
|
||||||
logger.debug("Getting extensions list from the internet")
|
|
||||||
lastUpdateCheck = System.currentTimeMillis()
|
|
||||||
|
|
||||||
val extensions =
|
val extensions =
|
||||||
(listOf(ExtensionGithubApi.REPO_URL_PREFIX) + serverConfig.extensionRepos.value).map { repo ->
|
(listOf(ExtensionGithubApi.REPO_URL_PREFIX) + serverConfig.extensionRepos.value).map { repo ->
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
@@ -51,13 +47,22 @@ object ExtensionsList {
|
|||||||
}
|
}
|
||||||
val foundExtensions = extensions.mapNotNull { it.getOrNull() }.flatten()
|
val foundExtensions = extensions.mapNotNull { it.getOrNull() }.flatten()
|
||||||
updateExtensionDatabase(foundExtensions)
|
updateExtensionDatabase(foundExtensions)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun fetchExtensionsCached() {
|
||||||
|
// update if 60 seconds has passed or requested offline and database is empty
|
||||||
|
if (lastUpdateCheck + 60.seconds.inWholeMilliseconds < System.currentTimeMillis()) {
|
||||||
|
logger.debug("Getting extensions list from the internet")
|
||||||
|
lastUpdateCheck = System.currentTimeMillis()
|
||||||
|
|
||||||
|
fetchExtensions()
|
||||||
} else {
|
} else {
|
||||||
logger.debug("used cached extension list")
|
logger.debug("used cached extension list")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getExtensionList(): List<ExtensionDataClass> {
|
suspend fun getExtensionList(): List<ExtensionDataClass> {
|
||||||
fetchExtensions()
|
fetchExtensionsCached()
|
||||||
return extensionTableAsDataClass()
|
return extensionTableAsDataClass()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user