Open mumische opened 2 years ago
The link to the actual code line:
Reading through the python questions, this sounds like a common confusion and I think you are right that this should be ab
instead of wb+
:
Wondering why nobody noticed this earlier.
I hit this issue yesterday, while testing sftp
feature with ansible-libssh
and noticed this problem.
I hit this issue yesterday, while testing
sftp
feature withansible-libssh
and noticed this problem.
Yeah. Should have been fixed with #638. Unfortunately not yet merged :(
SUMMARY
I'm trying to download configuration file from remote router and getting only last chunk of the file.
ISSUE TYPE
PYLISSH and LIBSSH VERSION
OS / ENVIRONMENT
Ubuntu 22.04 LTS Python 3.10.4
STEPS TO REPRODUCE
Narrowing the problem I wrote a piece of code below. You need a file on remote host to reproduce it.
EXPECTED RESULTS
File 'm8.rsc' in current directory, size of 16K
ACTUAL RESULTS
File 'm8.rsc', containing last 223b of source file.
As I found out, the problem lays in line #103 of sftp.pyx
In python3, "w" parameter truncates the file, so during reading the source file new data overwrites old. Please check and consider changing open mode to 'ab'