mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-23 13:23:28 +03:00
[download-cache] Fixed init logic to skip when cache file is missing (#10362)
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. Co-authored-by: Caleb Morris <347395+CalebMorris@users.noreply.github.com>
This commit is contained in:
parent
28e70ffd5d
commit
6ea76e0dbc
2 changed files with 14 additions and 8 deletions
|
@ -94,12 +94,15 @@ class AnimeDownloadCache(
|
|||
scope.launch {
|
||||
rootDownloadsDirLock.withLock {
|
||||
try {
|
||||
val diskCache = diskCacheFile.inputStream().use {
|
||||
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes())
|
||||
if (diskCacheFile.exists()) {
|
||||
val diskCache = diskCacheFile.inputStream().use {
|
||||
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes())
|
||||
}
|
||||
rootDownloadsDir = diskCache
|
||||
lastRenew = System.currentTimeMillis()
|
||||
}
|
||||
rootDownloadsDir = diskCache
|
||||
lastRenew = System.currentTimeMillis()
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" }
|
||||
diskCacheFile.delete()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,12 +105,15 @@ class MangaDownloadCache(
|
|||
scope.launch {
|
||||
rootDownloadsDirLock.withLock {
|
||||
try {
|
||||
val diskCache = diskCacheFile.inputStream().use {
|
||||
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes())
|
||||
if (diskCacheFile.exists()) {
|
||||
val diskCache = diskCacheFile.inputStream().use {
|
||||
ProtoBuf.decodeFromByteArray<RootDirectory>(it.readBytes())
|
||||
}
|
||||
rootDownloadsDir = diskCache
|
||||
lastRenew = System.currentTimeMillis()
|
||||
}
|
||||
rootDownloadsDir = diskCache
|
||||
lastRenew = System.currentTimeMillis()
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e) { "Failed to initialize disk cache" }
|
||||
diskCacheFile.delete()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue