Fix(storage): reclaim orphaned downloads and cap epub/pdf caches#75
Merged
Conversation
Clearing the entire library deleted DB rows and cache but never the offline downloads, orphaning them with no library rows and no UI to reclaim the space. There was also no way to see or bulk-clear downloads, and the epub_cache and pdf_images tiers had no size cap. - clearLibrary now also clears downloads and imported EPUBs, and cancels in-flight chapter downloads first (new ChapterDownloadQueue.cancelAll) - Settings shows Downloads size and a Clear all downloads action, which resets the download flag/badges for affected items - epub_cache and pdf_images get a 256 MB cap and join the auto-trim; trimming now runs after epub/pdf loads too, not just web loads
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.
Problem
"Clear entire library" deleted the DB rows and cache but left every offline download on disk, orphaned with no library rows and no UI to remove them. Downloads were also invisible in Settings (only cache size was shown) and could only be cleared one library item at a time. Separately,
epub_cacheandpdf_imageshad no size cap.Changes
clearLibrary()now also callsclearAllDownloads()andclearImportedEpubs(), and cancels in-flight chapter downloads first via a newChapterDownloadQueue.cancelAll().isDownloadedflag and refreshes badges for affected items.epub_cacheandpdf_imagesget a 256 MB cap and join the auto-trim. Trimming used to run only after web chapter loads; it now runs after epub/pdf loads too. The open epub's mtime is refreshed on access so it can't be evicted mid-read.Notes
Testing
./gradlew testStandardDebugUnitTest detekt— 480 tests, 0 failures, detekt clean./gradlew assembleStandardDebug assembleAiDebug— both flavors buildclearImportedEpubs, and epub/pdf cache trim (oldest-deleted, newest-survives).