Skip to content

fix: stream book file downloads#749

Merged
everpcpc merged 4 commits intomainfrom
codex/stream-book-downloads
Apr 29, 2026
Merged

fix: stream book file downloads#749
everpcpc merged 4 commits intomainfrom
codex/stream-book-downloads

Conversation

@everpcpc
Copy link
Copy Markdown
Owner

@everpcpc everpcpc commented Apr 29, 2026

Problem

Large original book downloads could buffer the full response in memory before writing to disk. CBR, EPUB, and PDF files can easily be hundreds of megabytes or larger, making macOS foreground downloads fragile and causing excessive progress notifications during high-throughput downloads.

After a file transfer completed, pending offline tasks and Live Activity state could also continue to display as Downloading 100% while extraction or finalization was still running.

Approach

Add a file-based download path in APIClient that uses URLSessionDownloadTask to stream responses into a temporary file, then moves the completed file into place only after a successful HTTP response. BookService.downloadBookFile now requires a destination URL, and offline CBR, EPUB, and PDF flows consume the downloaded file directly for extraction or storage.

Progress updates are throttled in DownloadProgressTracker so Observation-driven UI refreshes stay at a human-scale cadence while still delivering start and completion states immediately. Offline task rows and Live Activity updates now switch from download progress to a localized processing state once transfer work is complete but offline preparation continues.

Scope

  • Stream original book files to disk instead of returning large Data buffers
  • Route archive, EPUB, and PDF offline download flows through the file download API
  • Remove the unused progress data-buffering API
  • Throttle download progress UI updates
  • Show processing status after transfer completion while extraction/finalization continues
  • Localize the processing status text
  • Bump build version to 406

Validation

  • make format
  • make build-macos
  • make build

Download original book files directly to temporary files instead of buffering the full response in memory.

Route offline CBR, EPUB, and PDF downloads through the file streaming path and throttle download progress updates to avoid excessive Observation notifications.
Show a processing state once a pending offline task has finished the file transfer but still needs extraction or finalization.
Update offline task rows and Live Activity state after a file transfer reaches completion but extraction or finalization is still running.

Add localized processing text for all supported app languages.
@everpcpc everpcpc merged commit 23a9115 into main Apr 29, 2026
3 checks passed
@everpcpc everpcpc deleted the codex/stream-book-downloads branch April 29, 2026 09:22
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