Skip to content

FileSystem: a file system is named only at the start of a filename - #28

Merged
robdobsn merged 1 commit into
mainfrom
fix/fs-path-prefix
Oct 25, 2026
Merged

robdobsn merged 1 commit into
mainfrom
fix/fs-path-prefix

Conversation

@robdobsn

Copy link
Copy Markdown
Owner

Summary

getFilePath() and fsMutex() took local/ or sd/ anywhere in a filename as naming the file system:

  • Wrong file. A file in a folder called sd on the local file system was looked up at the wrong path. For example, filehash/local/test~sd~x.txt looked for /test/sd/x.txt, not /local/test/sd/x.txt.
  • Wrong lock. fsMutex() checked sd/ first, so a local file in a folder called sd was written holding the SD card's lock rather than the local one.

The new fileSystemNamedIn() recognises local or sd only at the start of the name, after an optional /, followed by / or nothing. getFilePath() and fsMutex() both use it, so the path and the lock always agree. Clients that name the file system send /<fs>/<path> (RaftCLI, raftjs), which is unchanged.

Testing

  • New test_file_system_paths (Linux), covering:

    • names that do name a file system: local/a, /sd/a, the bare sd;
    • names that don't: logs/sd/x.csv, /data/local/x, backup/nonlocal/x, sdcard/x.
  • make check passes.

  • On an Axiom:

    Uploading test/sd/x.txt with RaftCLI fileread/local/test~sd~x.txt
    Before Reported a failure: the file was written, but RaftCLI's filehash check got nofile nofile
    After Uploaded and verified Returns the file

🤖 Generated with Claude Code

getFilePath() and fsMutex() took "local/" or "sd/" anywhere in a filename as
naming the file system, so "logs/sd/x.csv" on the local file system was opened
as /logs/sd/x.csv (not /local/logs/sd/x.csv), and because fsMutex() checked
"sd/" first, a local file in a folder called sd was written holding the SD
card's lock rather than the local one.

fileSystemNamedIn() recognises "local" or "sd" only at the start of the name
(after an optional /), followed by / or nothing, and both use it, so the path
and the lock always agree. Clients that name the file system send
"/<fs>/<path>" (RaftCLI, raftjs), which is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robdobsn
robdobsn merged commit a4d3c35 into main Oct 25, 2026
1 check passed
@robdobsn
robdobsn deleted the fix/fs-path-prefix branch October 25, 2026 16:06
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