Conversation
choppeh
marked this pull request as draft
September 16, 2026 07:36
choppeh
force-pushed
the
bf/cache
branch
2 times, most recently
from
September 17, 2026 20:19
8afaaf0 to
f4217b7
Compare
choppeh
marked this pull request as ready for review
September 17, 2026 20:19
Member
|
Run |
Member
|
Imo the PR doesn’t solve #2030. Can you remove that from changelog and PR body |
- Use AtomicFile to ensure atomic reads/writes and prevent corrupted cache files on sudden termination - Synchronize initialization with initJob to prevent UI calls from triggering premature re-indexing - Embed createdAt and ttl in RootDirectory with isExpired check - Avoid premature disk writes before filesystem indexing completes - Guard UniFile serialization against nulls and Injekt errors
Allow users to configure the download cache time-to-live (TTL) in Advanced Settings, with a minimum threshold of 30 minutes.
Contributor
Author
Updated the changelog with the startup race condition fix |
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.
Closes #3526
Closes #2808
Closes #1429 (This will be fixed because the cache was no longer being pre-deleted; the current issue arises because the cache can be deleted, and reindexing halted, before the new cache is saved)
This PR fixes issues where the cache was lost on every app restart.
Previously, calling invalidateCache() deleted diskCacheFile immediately, leaving the cache cleared if renewal was cancelled or delayed, which caused downloaded chapters to incorrectly appear missing in the UI. Additionally, an uncoordinated startup sequence allowed UI queries to trigger full filesystem scans before the disk cache finished reading.
To resolve this, diskCacheFile now uses AtomicFile to prevent file corruption upon abrupt process termination, while initial disk loading is synchronized via initJob to ensure UI queries do not trigger premature re-indexing. Invalidation now marks RootDirectory as expired through its embedded creation timestamp and TTL rather than deleting the file upfront. Furthermore, disk writes are deferred until indexing successfully completes, and ProtoBuf serialization is made thread-safe
Additionally, a new preference has been added under Advanced Settings allowing users to customize the download cache recheck interval.
Images
Real device
Whenever the app was restarted, reindexing started from scratch. If there were many files to check, this could take a long time, becoming a problem when users opened and closed the app multiple times a day because the previous cache was lost.
Now, the cache is reused based on its lifespan.
issue.webm
fix.webm