remove update caching
This commit is contained in:
+2
-8
@@ -29,18 +29,13 @@ class BackendUpdateFetcher(
|
|||||||
private val dispatcherProvider: DispatcherProvider,
|
private val dispatcherProvider: DispatcherProvider,
|
||||||
private val userId: Long
|
private val userId: Long
|
||||||
) : UpdateFetcher {
|
) : UpdateFetcher {
|
||||||
private var config: UpdateInfo? = null
|
|
||||||
private var updateFile: File? = null
|
|
||||||
|
|
||||||
override suspend fun fetch(versionCode: Long): UpdateInfo = withContext(dispatcherProvider.io) {
|
override suspend fun fetch(versionCode: Long): UpdateInfo = withContext(dispatcherProvider.io) {
|
||||||
config?.let { return@withContext it }
|
|
||||||
val configPath = envFetcher.get("UPDATE_CONFIG")
|
val configPath = envFetcher.get("UPDATE_CONFIG")
|
||||||
if (configPath.isBlank()) {
|
if (configPath.isBlank()) {
|
||||||
UpdateInfo()
|
UpdateInfo()
|
||||||
} else {
|
} else {
|
||||||
json.decodeFromString<UpdateInfo>(File(configPath).readText()).apply {
|
json.decodeFromString<UpdateInfo>(File(configPath).readText())
|
||||||
config = this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +43,7 @@ class BackendUpdateFetcher(
|
|||||||
val updateFilePath = envFetcher.get("UPDATE_FILE")
|
val updateFilePath = envFetcher.get("UPDATE_FILE")
|
||||||
if (updateFilePath.isBlank()) throw HttpException(HttpStatusCode.NotFound.value, "Update not found")
|
if (updateFilePath.isBlank()) throw HttpException(HttpStatusCode.NotFound.value, "Update not found")
|
||||||
val file = File(updateFilePath)
|
val file = File(updateFilePath)
|
||||||
if (!file.exists()) error("File not exists")
|
if (!file.exists()) throw HttpException(HttpStatusCode.NotFound.value, "Update not exists")
|
||||||
updateFile = file
|
|
||||||
file
|
file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user