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:
schroda
2024-01-10 01:38:21 +01:00
committed by GitHub
parent c70c860a82
commit 6376972130

View File

@@ -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()
} }