Repository navigation
fix(offline): keep download finalize cheap and stop on database failures - #1333
Merged
Merged
Conversation
Finishing a download loaded the whole pending queue several times and, for series and read lists with an offline policy, reloaded every member book. Queue bookkeeping now reads counts or the single next book, and a book settling as downloaded updates rollups by delta. Download status and queue reads now throw instead of defaulting to not-downloaded or empty. OfflineManager stops on an unreadable status, removes files only after the status write landed, and does not advance the queue when the final status write failed, which previously re-picked the same book in a loop. In-transaction rollups throw so a failed member read rolls back instead of saving zeroed counts. Route SQLite's own error log into the Database log category so open failures carry the failing path and errno.
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.
Why
Follow-up to the offline report in #1330. Besides the deletion fixed in #1331, the reporter sees each download hang for ~30s after the file itself finishes, getting faster as the queue shrinks, and a persistent
SQLite error 14: unable to open database filewhose cause is still unknown.Download finalize no longer scales with the queue
Behavior note: policy-owned series and read lists used to get a full recount after every finished book. They now get one only when a failed state is involved or the delta goes out of bounds.
Database failures are no longer read as state
OfflineManagerstops at an unreadable status.These failures are logged only; no new user-facing alerts.
Diagnosing SQLite error 14
SQLite's own error log is now routed into the
Databaselog category. Unlike the thrownDatabaseError, it carries the failing system call, path, and errno, which should tell disk-full apart from descriptor exhaustion or a permission problem. Entries are capped per launch because persisting one writes to the log database.Validation
make build-ios,make build-macos, andmake build-tvospass. Not exercised on a device, with a large library, or against a failing database.Includes build 685.
🤖 Generated with Claude Code