Repository navigation
fix: makedirs of the home directory or the root with exist_ok - #99
Merged
Merged
Conversation
_parent returns "" for a top-level path, and makedirs("", exist_ok=True)
failed with FileNotFoundError: asyncssh sends mkdir(""), which the
server rejects. fsspec's generic code creates parents with
makedirs(_parent(path), exist_ok=True), so writing a top-level key
through get_mapper("") failed. makedirs now returns early for "" and
"/" when exist_ok is set, since both always exist.
Fixes #93.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The guard omits supported bytes paths, so makedirs(b"", exist_ok=True) still sends a rejected empty-path request and the home-directory fix remains unavailable when path_encoding=None.
1 open issue
What changed in this PR
This PR fixes home-directory creation for fsspec’s parent-directory workflow, enabling writes through get_mapper("") and addressing #93.
Changes:
- Skip directory creation for
""and"/"whenexist_ok=True, while preserving strict creation behavior. - Add regression tests for home/root paths and top-level mapper writes.
| File | Description |
|---|---|
tests/test_sshfs.py |
Tests home/root directory creation and top-level mapper writes. |
sshfs/spec.py |
Adds an early return for home/root paths when exist_ok=True. |
Review effort: Balanced
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.

_parentreturns""for a top-level path, andmakedirs("", exist_ok=True)fails withFileNotFoundError, because asyncssh sendsmkdir(""), which the server rejects. fsspec's generic code creates parent directories withmakedirs(fs._parent(path), exist_ok=True), so this failed:makedirsnow returns early for""(the home directory) and"/"whenexist_okis set, since both always exist. Withexist_ok=Falseit behaves as before."/"already worked against the test server, but skipping it also saves requests and doesn't depend on how a server answersmkdir("/").The
_parentchecks that #91 added toput_fileandpipe_filebecome redundant with this. #89's PR removes them.The test for
""and theget_mappertest fail onmain.Fixes #93.
🤖 Generated with Claude Code