Skip to content

feat(sftp): prefer posix-rename@openssh.com extension when available#172

Merged
vicajilau merged 2 commits into
TerminalStudio:masterfrom
lollipopkit:upstream/sftp-posix-rename
Jun 30, 2026
Merged

feat(sftp): prefer posix-rename@openssh.com extension when available#172
vicajilau merged 2 commits into
TerminalStudio:masterfrom
lollipopkit:upstream/sftp-posix-rename

Conversation

@GT-610

@GT-610 GT-610 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

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.

Changes

  • Add SftpPosixRenameRequest extended request type in sftp_packet_ext.dart.
  • Rewrite SftpClient.rename to probe the handshake extensions and use the extended request when available, falling back to SSH_FXP_RENAME on SftpExtensionError.
  • Add protocol-level tests for both the extension path and the fallback path.

Test plan

  • test/src/sftp/sftp_client_protocol_test.dart — all 12 tests pass (including 2 new).
  • Verified fallback test exercises SSH_FXP_RENAME when no extension advertised.
  • Verified extension test sends SftpExtendedPacket when extension advertised.

Backport of ServerBox's forked dartssh2.

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.
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.77%. Comparing base (ba899d8) to head (80b92c6).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
lib/src/sftp/sftp_client.dart 87.50% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 53.77% <91.66%> (+0.43%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lib/src/sftp/sftp_packet_ext.dart 100.00% <100.00%> (ø)
lib/src/sftp/sftp_client.dart 56.64% <87.50%> (+5.56%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vicajilau vicajilau merged commit 0da4239 into TerminalStudio:master Jun 30, 2026
3 checks passed
@GT-610 GT-610 deleted the upstream/sftp-posix-rename branch July 1, 2026 03:05
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.

2 participants