fix(cache): prevent random FileNotFoundException when reading chapters#3154
Open
leodyversemilla07 wants to merge 2 commits intomihonapp:mainfrom
Open
fix(cache): prevent random FileNotFoundException when reading chapters#3154leodyversemilla07 wants to merge 2 commits intomihonapp:mainfrom
leodyversemilla07 wants to merge 2 commits intomihonapp:mainfrom
Conversation
Member
|
500 MB cache is aggressive. I don't think the lower end devices Mihon is used on could handle that well. |
Contributor
Author
what do you think would be the sweet spot? |
Contributor
Author
|
I've reduced the cache size to 200 MiB (doubling the original 100 MiB) to be less aggressive for lower-end devices while still providing more headroom for high-res images. The primary fix of adding physical file existence checks remains unchanged. |
- Increase chapter cache size to 500 MiB to reduce aggressive evictions. - Add physical file existence check in isImageInCache to detect stale index entries. - Add warning log for index/disk desynchronization. Fixes mihonapp#2740
14cca97 to
c58cf8f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses the random
FileNotFoundExceptionreported in #2740 by making chapter cache validation more robust and increasing its capacity.The Bug
The chapter cache validation was previously only checking the cache index (journal). If the index was stale or the physical file had been evicted/deleted (due to the small 100MB limit or OS intervention), the loader would erroneously skip the download and attempt to open a non-existent file.
The Fix
.exists()check inisImageInCacheto ensure the file is actually present on disk before reporting it as cached.logcatwarning when the index and disk are out of sync to aid future diagnostics.Checklist
isImageInCachecorrectly triggers re-downloads when files are manually deleted from the cache directory.Fixes #2740