diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt index 176099cd6..b40686e78 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloadCache.kt @@ -94,12 +94,15 @@ class AnimeDownloadCache( scope.launch { rootDownloadsDirLock.withLock { try { - val diskCache = diskCacheFile.inputStream().use { - ProtoBuf.decodeFromByteArray(it.readBytes()) + if (diskCacheFile.exists()) { + val diskCache = diskCacheFile.inputStream().use { + ProtoBuf.decodeFromByteArray(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() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt index ecf28e5a0..54cece8bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/manga/MangaDownloadCache.kt @@ -105,12 +105,15 @@ class MangaDownloadCache( scope.launch { rootDownloadsDirLock.withLock { try { - val diskCache = diskCacheFile.inputStream().use { - ProtoBuf.decodeFromByteArray(it.readBytes()) + if (diskCacheFile.exists()) { + val diskCache = diskCacheFile.inputStream().use { + ProtoBuf.decodeFromByteArray(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() } }