Move SFTPClient.get() termination condition to loop end.
Ensures callback always executes even for zero-len files. Fixes #90
This commit is contained in:
parent
8e5f774965
commit
1341e28882
4
NEWS
4
NEWS
|
@ -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)
|
||||
---------------------
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue