feat(sftp): tar transfers for Windows OpenSSH hosts (#345) - #352
Merged
Merged
Conversation
Windows 10 1803+ ships bsdtar as tar.exe, so multi-item transfers to and from Win32-OpenSSH hosts no longer need the per-file fallback #341 put them on. The tar probe now identifies the remote shell once per session: POSIX first, then cmd.exe (`%TEMP%` expands) or PowerShell (`$env:TEMP` expands), each followed by a `tar --version` check. Tar commands are written in that shell's dialect: native `C:\...` paths from the SFTP `/C:/...` form, the archive staged in `%TEMP%`, exit codes reported without cmd's parse-time `%errorlevel%`, and symlinks dereferenced when the extracting end is Windows. cmd.exe's 8191-char command line limit is checked instead of failing with a truncated command. Compress/extract in the context menu use the same dialect, so they now work on Windows hosts too.
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.
Closes #345.
What
Multi-item SFTP transfers to/from Win32-OpenSSH hosts use tar acceleration again, through the host's own
tar.exe(bsdtar, shipped since Windows 10 1803), instead of the per-file fallback from #341.How
sftp_tar_availablenow detects the remote shell once per SFTP session (cached on the session entry):command -v tar && test -d /tmpecho __TF_TEMP__:%TEMP%— only cmd.exe expands it'__TF_TEMP__:' + $env:TEMP— only PowerShell expands ittar --versionin the detected dialectAll probes are harmless on any shell. The temp value must look like
X:\..., otherwise it is rejected.RemoteShell(commands/sftp/remote_shell.rs) writes tar commands for the detected shell:/C:/a/b→ nativeC:\a\b. A drive root becomesC:\.because a bareC:means the current directory on that drive.%TEMP%(in SFTP form for the upload/download step)&& … || …, because%errorlevel%expands at parse time. PowerShell uses$LASTEXITCODE, captured before cleanup.Testing
cargo test --lib commands::sftp: 22 pass, with new tests for detection parsing, path mapping, quoting and per-shell status/cleanup.cargo clippy --libis clean.mcr.microsoft.com/powershell(pwsh 7): probe,tar --versionwith and without tar, create with'and spaces in names, extract with mkdir and cleanup, and a failed extract reporting exit 2.DefaultShell, before release.Known limits
%VAR%for a defined variable gets expanded inside the quotes (cmd has no escape for this).