fix(sftp): wire asyncssh progress_handler for transfer progress - #47
Closed
Orinks wants to merge 6 commits into
Closed
fix(sftp): wire asyncssh progress_handler for transfer progress#47Orinks wants to merge 6 commits into
Orinks wants to merge 6 commits into
Conversation
Adds native PPK v2 support for SFTP site authentication, matching WinSCP behaviour. Users can now select a .ppk file directly when configuring a site — no manual conversion required. Implementation: - New ppk_utils.py: is_ppk_file() detects .ppk extension; load_ppk_key() converts PPK → OpenSSH in-memory via puttykeys + paramiko, nothing written to disk - protocols.py: when key_path ends in .ppk, route through load_ppk_key() and pass pkey= to paramiko instead of key_filename= - Passphrase-protected PPK files use the existing password field - puttykeys added as a dependency (uses cryptography, already installed) Supports RSA and Ed25519 key types (PPK v2). PPK v3 users can convert with PuTTYgen. Closes #43
Replace paramiko with asyncssh for all SFTP operations. asyncssh handles PPK v2/v3 keys natively (no puttykeys conversion needed) and provides non-blocking IO via a dedicated event loop on a background thread, eliminating the UI freeze workarounds (daemon threads, _sftp_lock, _listdir_attr_safe) that were needed with paramiko. Changes: - Rewrite SFTPClient in protocols.py to use asyncssh with a dedicated asyncio event loop on a daemon thread - Remove ppk_utils.py (asyncssh handles PPK natively) - Remove puttykeys dependency, add asyncssh>=2.14 - Simplify host_key_policy.py and ssh_utils.py (remove paramiko code) - Update all tests to use asyncssh mocks - Update PyInstaller spec for asyncssh Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After the asyncssh migration, SFTP downloads/uploads showed 0% progress because the manual chunk-read loop bypassed asyncssh's pipelined I/O and native progress reporting. Switch SFTPClient.download() and upload() to use sftp.get()/sftp.put() with their progress_handler callback. This gives pipelined reads/writes for better throughput and correct progress updates via the existing wx.PostEvent thread-safe notification path. A chunked-read fallback is retained for in-memory BinaryIO streams (BytesIO) used in tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes #45 — file downloads/uploads stuck at 0% after the asyncssh migration (PR #44).
SFTPClient.download()andupload()used a manual chunk-read loop viasftp.open()+rf.read(8192), bypassing asyncssh's pipelined I/O and nativeprogress_handlercallback. Progress callbacks fired on the asyncio event loop thread but without asyncssh's built-in reporting, the UI never received timely updates.sftp.get()/sftp.put()with theirprogress_handlerparameter for pipelined reads/writes and correct progress reporting. The existingwx.PostEventinTransferManager._notify()is already thread-safe, so progress callbacks from the asyncio thread reach the wx main thread correctly.BinaryIOstreams (BytesIO) used in unit tests.Test plan
ruff checkandruff formatpass with no issuespytest tests/ -v)TestSFTPClientNativeTransferclass validates:sftp.get()called withprogress_handlerfor downloads with file pathssftp.put()called withprogress_handlerfor uploads with file paths(bytes_copied, total_bytes)tuplesBytesIOobjects fall back to chunked read/write (nosftp.get/put)🤖 Generated with Claude Code