fix(library): decide book availability from metadata, not read probes - #293
Merged
Conversation
Every book in the library showed the iCloud download overlay even though all files were fully materialized and opened fine. Two causes, both in the first-byte read probe that #289 made the availability signal: - Cold first-byte reads through fileproviderd take 0.7-8s on healthy downloaded files (measured across a 357-book library), so the 300ms probe deadline marked virtually every book unavailable. - Concurrent probes of the same path short-circuit to "unavailable" via the in-flight marker, so two overlapping list_books calls (Home refreshes from several event listeners) poisoned each other's results wholesale. Availability is now metadata-only: the file has metadata (legacy .icloud-rename eviction leaves none at the real path) and doesn't carry SF_DATALESS (FileProvider-style eviction). No reads, no deadline, no per-book probe threads in list_books. The read probe survives as is_file_readable behind a new check_book_readable command, used only where #289 needed it: after a reader load failure, to tell broken iCloud sync from a broken book (and nudge a re-download). Same bounded-wait and in-flight guarantees, now covered by tests under the new name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
yicheng47
force-pushed
the
fix/icloud-availability-metadata
branch
from
August 8, 2026 15:25
5c549f0 to
bfb1df9
Compare
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
Every book in the library shows the iCloud download overlay even though all files are fully materialized on disk and open fine in the reader.
Cause
#289 made availability a first-byte read probe with a 300ms deadline. Measured against a real 357-book library, that breaks two ways:
list_bookstherefore marks the whole page unavailable. (Warm reads are fast, which is why the reader still opens books after a beat.)PROBES_IN_FLIGHTguard reports "unavailable" for any path already being probed. Home triggerslist_booksfrom several event listeners; in a two-sweep race over warm files, one call reported 323/357 unavailable and the other 34.Fix
is_file_downloadedis now metadata-only: the file has metadata (legacy.icloud-rename eviction leaves none at the real path) and doesn't carrySF_DATALESS(FileProvider-style eviction). No reads, no deadline, andlist_booksdrops its per-book probe threads.is_file_readablebehind a newcheck_book_readablecommand, used only where fix(reader): surface error when iCloud book file is unreadable #289 needed it: after a reader load failure, to distinguish broken iCloud sync from a broken book (and nudge a re-download). Same bounded-wait and in-flight guarantees.Testing
is_file_readable, plus a new test pinning that a hanging path counts as downloaded but not readabletsc --noEmitandcargo clippyclean🤖 Generated with Claude Code