Skip to content

Fix(storage): reclaim orphaned downloads and cap epub/pdf caches#75

Merged
Aatricks merged 1 commit into
mainfrom
fix/storage-deletion-path
Jul 6, 2026
Merged

Fix(storage): reclaim orphaned downloads and cap epub/pdf caches#75
Aatricks merged 1 commit into
mainfrom
fix/storage-deletion-path

Conversation

@Aatricks

@Aatricks Aatricks commented Jul 6, 2026

Copy link
Copy Markdown
Owner

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_cache and pdf_images had no size cap.

Changes

  • clearLibrary() now also calls clearAllDownloads() and clearImportedEpubs(), and cancels in-flight chapter downloads first via a new ChapterDownloadQueue.cancelAll().
  • Settings: new "Downloads size" row and "Clear all downloads" button. Clearing resets the isDownloaded flag and refreshes badges for affected items.
  • epub_cache and pdf_images get 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

  • ~400 MB "Cache" is expected: the media cache is capped at 512 MB and auto-trimmed.
  • Normal reading does not grow "Data" — only explicit offline downloads do.

Testing

  • ./gradlew testStandardDebugUnitTest detekt — 480 tests, 0 failures, detekt clean
  • ./gradlew assembleStandardDebug assembleAiDebug — both flavors build
  • New tests: clearLibrary/clearAllDownloads wiring + flag reset, real-disk clearImportedEpubs, and epub/pdf cache trim (oldest-deleted, newest-survives).

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
@Aatricks Aatricks merged commit 606f9d9 into main Jul 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant