Prevent random FileNotFoundException when reading chapters (#3154)

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Leodyver Semilla
2026-06-24 00:44:27 +08:00
committed by GitHub
parent a1b5ea811a
commit bc7f7e70a1
2 changed files with 8 additions and 1 deletions
@@ -113,7 +113,13 @@ class ChapterCache(
*/
fun isImageInCache(imageUrl: String): Boolean {
return try {
diskCache.get(DiskUtil.hashKeyForDisk(imageUrl)).use { it != null }
val key = DiskUtil.hashKeyForDisk(imageUrl)
val inJournal = diskCache.get(key).use { it != null }
val fileExists = getImageFile(imageUrl).exists()
if (inJournal && !fileExists) {
logcat(LogPriority.WARN) { "Image is in journal but file is missing: $imageUrl" }
}
inJournal && fileExists
} catch (_: IOException) {
false
}