Repository navigation
Add UploadDir to upload a local directory - #12
Merged
Merged
Conversation
This was referenced Oct 12, 2026
UploadDir walks a local directory and recreates it on the remote server over a single SFTP connection, preserving file and directory permissions and skipping symlinks. Upload now shares an uploadFile helper and closes the remote file, returning any close error. Closes #11
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 #11.
Summary
Client.UploadDir(local, remote string) error, which recursively uploads a local directory over a single SFTP connection.MkdirAll.path.Joinso uploads from Windows produce/-separated paths.Uploadnow shares anuploadFilehelper and closes the remote file, returning any close error. Previously the remote file was never closed, so a failed final write could go unnoticed.Uploaddoes not change file modes, as before.Usage
Testing
simplessh_test.go(the repo's first tests), using an in-processpkg/sftpserver, so no SSH host is needed. Covers file contents, permissions, nested/empty directories, a non-existent remote target, skipped symlinks, and a missing local directory.go test -race ./...passes. Not yet tested against a real SSH server.