From bc7f7e70a1de65f1f966e2e31f97457f8ac16ce6 Mon Sep 17 00:00:00 2001 From: Leodyver Semilla <124951048+leodyversemilla07@users.noreply.github.com> Date: Wed, 24 Jun 2026 00:44:27 +0800 Subject: [PATCH] Prevent random `FileNotFoundException` when reading chapters (#3154) Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- CHANGELOG.md | 1 + .../java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e540de1..bf0fa3a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co ### Fixed - Add missing `outlineVariant` color to Nord theme ([@CompileConnected](https://github.com/CompileConnected)) ([#3184](https://github.com/mihonapp/mihon/pull/3184)) - Continue reading button missing when unread filter is off ([@AntsyLich](https://github.com/AntsyLich)) ([#3382](https://github.com/mihonapp/mihon/pull/3382)) +- Fix random `FileNotFoundException` when reading chapters ([@leodyversemilla07](https://github.com/leodyversemilla07)) ([#3154](https://github.com/mihonapp/mihon/pull/3154)) ## [v0.19.9] - 2026-04-11 ### Fixed diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt index 1d47f5b7d..2913b2fdb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt @@ -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 }