Repository navigation
perf: create upload parents only when the upload fails without them - #101
Merged
Merged
Conversation
put_file and pipe_file called makedirs on the parent before every upload, and asyncssh's makedirs sends a MKDIR, plus a STAT when the directory exists, for each path component. Uploads now run first and create the parents and retry only when they fail with SFTPNoSuchFile. The retry takes a new channel, so an upload never holds one channel while waiting for another. A put_file whose local file is missing no longer creates the remote parent directories before failing. Fixes #89. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use asyncssh.SFTPNoSuchFile instead of editing the asyncssh.sftp import, and define the makedirs_calls fixture next to the tests that use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Both upload methods fail to create missing parent directories when SFTP v4+ servers raise SFTPNoSuchPath, regressing automatic directory creation.
1 open issue
What changed in this PR
This PR reduces SFTP round trips for uploads into existing directories, addressing #89 while preserving the relative and top-level path handling from #91.
Changes:
- Attempts uploads first, creating missing parents and retrying on a fresh channel after
SFTPNoSuchFile. - Avoids creating remote directories when the local upload file is missing.
- Adds tests for skipped directory creation, missing-parent recovery, and missing local files.
| File | Description |
|---|---|
tests/test_sshfs.py |
Records directory-creation calls and tests the updated upload behavior. |
sshfs/spec.py |
Shares upload-first retry logic between put_file and pipe_file. |
Review effort: Balanced
With SFTP v4 and later, a server can report a missing parent directory as SFTPNoSuchPath, which isn't a subclass of SFTPNoSuchFile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shcheklein
added a commit
that referenced
this pull request
Nov 29, 2026
Avoids a conflict with #101, which changes the asyncssh.sftp import next to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shcheklein
added a commit
that referenced
this pull request
Nov 29, 2026
* perf: run uname once per filesystem instead of on every checksum checksum ran uname on the server before every md5sum or md5 command to pick between them. The server's OS can't change while the filesystem is connected, so _get_system now caches the result. Fixes #90. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: run uname once when the first checksums are concurrent Concurrent first calls each saw no cached result and ran their own uname. A lock now makes them wait for one, and the test covers concurrent first calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: patch the client's class instead of importing it Avoids a conflict with #101, which changes the asyncssh.sftp import next to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

put_fileandpipe_filecallmakedirson the parent before every upload, and asyncssh'smakedirssends aMKDIRfor each path component, plus aSTATwhen the directory exists. Uploads into an existing directory paid about two round trips per component.Uploads now run first, and create the parent directories and retry only when they fail with
SFTPNoSuchFile. The retry takes a new channel, so an upload never holds one channel while waiting for another. Top-level paths, whose parent is"", never retry, as before (#91).SFTP requests counted against the test server by wrapping
SFTPClientHandler._make_request, for a directory 20 levels deep:mainput_fileinto an existing directorypipe_fileinto an existing directoryput_fileinto a new directoryOne behavior change: a
put_filewhose local file is missing no longer creates the remote parent directories before failing.The tests record asyncssh's
SFTPClient.makedirscalls. Uploads into an existing directory make none,pipe_fileinto a new nested directory makes one, and a missing local file leaves no remote directory behind.Fixes #89.
🤖 Generated with Claude Code