1
0
mirror of https://github.com/mihonapp/mihon.git synced 2025-03-24 05:20:04 +01:00

[download-cache] Fixed init logic to skip when cache file is missing ()

There are several possible causes of the cache file to not exist, including user
 action. By skipping these couple steps during initialization when the file is
 missing, a renew action is allowed to start and the cache will rebuild and
 hopefully work as expected.

Simple fix for 
This commit is contained in:
Caleb Morris 2024-01-11 16:23:18 -07:00 committed by GitHub
parent b1067b942e
commit 7292dadd5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -103,12 +103,15 @@ class DownloadCache(
scope.launch { scope.launch {
rootDownloadsDirLock.withLock { rootDownloadsDirLock.withLock {
try { try {
val diskCache = diskCacheFile.inputStream().use { if (diskCacheFile.exists()) {
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes()) val diskCache = diskCacheFile.inputStream().use {
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes())
}
rootDownloadsDir = diskCache
lastRenew = System.currentTimeMillis()
} }
rootDownloadsDir = diskCache
lastRenew = System.currentTimeMillis()
} catch (e: Throwable) { } catch (e: Throwable) {
logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" }
diskCacheFile.delete() diskCacheFile.delete()
} }
} }