diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2012-10-14 21:46:50 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2012-10-14 21:46:50 -0700 |
commit | 1341e28882998a08fa2bf00c21047207dff3e18a (patch) | |
tree | a6a01cc570d31f65453528464ef450d02b260ec0 | |
parent | 8e5f774965bc281b8154379f68e6152356eedfd8 (diff) |
Move SFTPClient.get() termination condition to loop end.
Ensures callback always executes even for zero-len files.
Fixes #90
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | paramiko/sftp_client.py | 4 |
2 files changed, 6 insertions, 2 deletions
@@ -15,6 +15,10 @@ Releases v1.8.1 (DD MM YYYY) ------------------- +* #90: Ensure that callbacks handed to `SFTPClient.get()` always fire at least + once, even for zero-length files downloaded. Thanks to Github user `@enB` for + the catch. + v1.8.0 (3rd Oct 2012) --------------------- diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index f446ba3d..3eaefc9c 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -612,12 +612,12 @@ class SFTPClient (BaseSFTP): size = 0 while True: data = fr.read(32768) - if len(data) == 0: - break fl.write(data) size += len(data) if callback is not None: callback(size, file_size) + if len(data) == 0: + break finally: fl.close() finally: |