feat(sftp): prefer posix-rename@openssh.com extension when available#172
Merged
vicajilau merged 2 commits intoJun 30, 2026
Merged
Conversation
The SFTP rename method now prefers the posix-rename@openssh.com extension (version 1) when advertised by the server. This performs an atomic rename with POSIX semantics (replace destination if it exists), matching the behavior of OpenSSH's sftp client. If the server does not advertise the extension, or advertises an incompatible version, the method transparently falls back to the standard SSH_FXP_RENAME request, preserving existing behavior. - Add SftpPosixRenameRequest extended request type. - Rewrite SftpClient.rename to probe the handshake extensions and use the extended request when available. - Add protocol-level tests for both the extension path and the fallback path.
3 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #172 +/- ##
==========================================
+ Coverage 53.33% 53.77% +0.43%
==========================================
Files 64 64
Lines 5186 5198 +12
==========================================
+ Hits 2766 2795 +29
+ Misses 2420 2403 -17
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Summary
The SFTP
renamemethod now prefers theposix-rename@openssh.comextension (version 1) when advertised by the server. This performs an atomic rename with POSIX semantics (replace destination if it exists), matching the behavior of OpenSSH'ssftpclient.If the server does not advertise the extension, or advertises an incompatible version, the method transparently falls back to the standard
SSH_FXP_RENAMErequest, preserving existing behavior.Changes
SftpPosixRenameRequestextended request type insftp_packet_ext.dart.SftpClient.renameto probe the handshake extensions and use the extended request when available, falling back toSSH_FXP_RENAMEonSftpExtensionError.Test plan
test/src/sftp/sftp_client_protocol_test.dart— all 12 tests pass (including 2 new).SSH_FXP_RENAMEwhen no extension advertised.SftpExtendedPacketwhen extension advertised.Backport of ServerBox's forked dartssh2.