Skip to content

feat: add native SFTP directory operations and internalize SSH client#5

Merged
inureyes merged 5 commits into
mainfrom
refactor/sftp-struct
Aug 22, 2025
Merged

feat: add native SFTP directory operations and internalize SSH client#5
inureyes merged 5 commits into
mainfrom
refactor/sftp-struct

Conversation

@inureyes
Copy link
Copy Markdown
Member

@inureyes inureyes commented Aug 22, 2025

Summary

  • Internalized the async-ssh2-tokio library as src/ssh/tokio_client/ module
  • Added native SFTP directory upload/download operations using russh-sftp
  • Removed unused duplicate SFTP module implementation
  • Improved performance with single-connection directory transfers

Major Changes

1. Internalized SSH Client Library

  • Moved async-ssh2-tokio source code to src/ssh/tokio_client/
  • Direct dependency on russh and russh-sftp instead of wrapper library
  • Full control over SSH client implementation for future enhancements

2. Native Directory Operations

  • upload_dir(): Recursively uploads directories using SFTP's native methods
  • download_dir(): Recursively downloads directories using SFTP's readdir
  • Automatic detection: uploads/downloads switch between file and directory methods based on path type
  • Single SSH connection for entire directory transfer (previously: connection per file)

3. Code Cleanup

  • Removed entire unused src/sftp/ module (8 files, ~2000 lines)
  • Cleaned up duplicate implementations
  • Maintained backward compatibility with existing CLI commands

Performance Improvements

  • Before: Multiple SSH connections (one per file) for directory operations
  • After: Single SSH connection with SFTP session for entire directory tree
  • Significant speed improvement for directories with many files

User Impact

  • No breaking changes - All existing commands work identically
  • ✅ Same CLI interface (-r flag for recursive operations)
  • ✅ Better performance for directory transfers
  • ✅ More reliable handling of special characters in filenames

Test Results

  • Unit tests: 24 passed ✅
  • Integration tests: 31 passed ✅
  • Doc tests: 2 passed ✅
  • Total: 57 tests, all passing

Example Usage (unchanged)

# Upload directory recursively
bssh -c cluster upload -r ./local_dir /remote/path/

# Download directory recursively  
bssh -c cluster download -r /remote/dir ./local/

@inureyes inureyes added the type:refactor Code refactoring label Aug 22, 2025
@inureyes inureyes changed the title refactor: internalize async-ssh2-tokio as tokio_client module feat: add native SFTP directory operations and internalize SSH client Aug 22, 2025
@inureyes inureyes added type:enhancement New feature or request and removed type:refactor Code refactoring labels Aug 22, 2025
@inureyes inureyes self-assigned this Aug 22, 2025
@inureyes inureyes merged commit ccec98e into main Aug 22, 2025
2 checks passed
@inureyes inureyes added priority:high High priority issue status:done Completed feature labels Sep 9, 2025
@inureyes inureyes deleted the refactor/sftp-struct branch October 30, 2025 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority issue status:done Completed type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant