Skip to content

Keep the mode, refuse a short download, and stop claiming disk we do not use - #55

Merged
franzjeger merged 1 commit into
mainfrom
fix/conformance-5-3-5-7-5-8
Aug 8, 2026
Merged

franzjeger merged 1 commit into
mainfrom
fix/conformance-5-3-5-7-5-8

Conversation

@franzjeger

Copy link
Copy Markdown
Owner

Three findings from an external conformance suite that states what a cloud file
must answer and checks it through a real mount, a real sync engine and a real
database.

Worth saying first: five of its eight invariants already passed, including
the two hardest. The atomic-save and delete-during-upload races fixed in #52 and
#51 both held up under a test that was not written by whoever fixed them.

chmod +x returned success and changed nothing

setattr accepted a mode change and dropped it, and every attribute answer used
a hardcoded 0o644. OneDrive has nowhere to store a mode, so it lives here or
not at all — and the exec bit is the one that matters, because losing it turns a
working script into one that will not run, with nothing to point at.

Modes now live in their own table, the way local-only symlinks already do, and
are held in memory because every stat reads them and a stat must not become
a query.

The second half only showed up under the suite, and was worse. The mode is keyed
by item ID, and a created file's ID changes when the upload adopts the real
OneDrive one. A chmod +x made before the upload landed was orphaned under a
_local_* key nothing would ever ask about again — so it applied right up until
the file finished uploading, and then quietly stopped. The cache file already
moves across adoption; the mode moves with it now.

A download that ended early was served as a short file

A placeholder's size comes from the delta pass. If the object changes on
OneDrive before anyone reads it, the stream ends at a different length — and a
completed download was taken to mean a correct one. The reader asked about a
4096-byte file and got 2048, with no error, and because getattr answers from
the cache file the wrong size then became what stat reported from then on.

A hydration now either brings what the row promised or nothing: the partial copy
is discarded, the row stays a placeholder so the next open tries again, and
the reader gets EIO rather than a file that is quietly not what it asked for.

A placeholder claimed disk it was not using

blocks was computed from size, so a cloud-only file reported a full
allocation. That makes du -sh ~/OneDrive report the whole drive — on-demand
cannot be seen to be working even when it is — and the cache-size policy reads
those numbers. blocks now comes from the cached copy, and is zero when there
is not one.

Tests

Two mount round trips: one for the mode across an ID adoption, one for the short
download, which also asserts the placeholder's blocks. Both confirmed to fail
before the corresponding fix
(git stash the two source files, run, watch them
go red). The five existing round trips and the rest of the suite are unchanged —
137 tests green.

Where the suite lives

https://github.com/franzjeger/HydrationAPI — the invariants are written against
a trait that knows nothing about any implementation, so they outlive the
architecture. cargo test -p adapter-onedrive-reference runs them against this
client. Against this branch: 8 passed, 0 failed.

🤖 Generated with Claude Code

…not use

Three findings from an external conformance suite that states what a cloud
file must answer and checks it through a real mount. Five of its eight
invariants already passed, including the two hardest — the atomic save and
the delete-during-upload races fixed in #52 and #51 both held up under a
test that was not written by whoever fixed them.

**`chmod +x` returned success and changed nothing.** setattr accepted a
mode change and dropped it on the floor, and every attribute answer used a
hardcoded 0o644. OneDrive has nowhere to store a mode, so it has to live
here or not at all — and the exec bit is the one that matters, because
losing it turns a working script into one that will not run with nothing
to point at. Modes now live in their own table, the same way local-only
symlinks already do, and are held in memory because every stat reads them
and a stat must not become a query.

The second half of that was worse and only showed up under the suite. The
mode is keyed by item ID, and a created file's ID changes when the upload
adopts the real OneDrive one. A `chmod +x` made before the upload landed
was orphaned under a `_local_*` key nothing would ever ask about again, so
it applied right up until the file finished uploading and then quietly
stopped. The cache file already moves across adoption; the mode moves with
it now.

**A download that ended early was served as a short file.** The size of a
placeholder comes from the delta pass. If the object changes on OneDrive
before anyone reads it, the stream ends at a different length — and we
took a completed download to mean a correct one. The reader had asked
about a 4096-byte file and got 2048, with no error, and because getattr
answers from the cache file the wrong size then became what stat reported
from then on. A hydration now either brings what the row promised or it
brings nothing: the partial copy is discarded, the row stays a
placeholder so the next open tries again, and the reader gets EIO instead
of a file that is quietly not what it asked for.

**A placeholder claimed disk it was not using.** blocks was computed from
size, so a cloud-only file reported a full allocation. That makes
`du -sh ~/OneDrive` report the whole drive, which means on-demand cannot
be seen to be working even when it is — and the cache-size policy reads
those numbers. blocks now comes from the cached copy, and is zero when
there is not one.

Tests: two mount round trips, one for the mode across an adoption and one
for the short download, which also asserts the placeholder's blocks.
Both confirmed to fail before the corresponding fix. The five existing
round trips and the rest of the suite are unchanged.
@franzjeger
franzjeger force-pushed the fix/conformance-5-3-5-7-5-8 branch from ea39b06 to f400a0e Compare August 8, 2026 19:44
@franzjeger
franzjeger merged commit a6312a8 into main Aug 8, 2026
3 checks passed
@franzjeger
franzjeger deleted the fix/conformance-5-3-5-7-5-8 branch August 8, 2026 19:47
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