File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,16 @@ cdef class SFTP:
91
91
if rf is NULL :
92
92
raise LibsshSFTPException(" Opening remote file [%s ] for read failed with error [%s ]" % (remote_file, self ._get_sftp_error_str()))
93
93
94
- while True :
95
- file_data = sftp.sftp_read(rf, < void * > read_buffer, sizeof( char ) * 1024 )
96
- if file_data == 0 :
97
- break
98
- elif file_data < 0 :
99
- sftp.sftp_close(rf)
100
- raise LibsshSFTPException( " Reading data from remote file [ %s ] failed with error [ %s ] "
101
- % (remote_file, self ._get_sftp_error_str()))
102
-
103
- with open (local_file, ' ab ' ) as f:
94
+ with open (local_file, ' wb ' ) as f :
95
+ while True :
96
+ file_data = sftp.sftp_read(rf, < void * > read_buffer, sizeof( char ) * 1024 )
97
+ if file_data == 0 :
98
+ break
99
+ elif file_data < 0 :
100
+ sftp.sftp_close(rf)
101
+ raise LibsshSFTPException( " Reading data from remote file [ %s ] failed with error [ %s ] "
102
+ % (remote_file, self ._get_sftp_error_str()))
103
+
104
104
bytes_written = f.write(read_buffer[:file_data])
105
105
if bytes_written and file_data != bytes_written:
106
106
sftp.sftp_close(rf)
You can’t perform that action at this time.
0 commit comments