mattnenterprise / rust-ftp

FTP client for Rust
Apache License 2.0
182 stars 57 forks source link

File size increase on download tranfer #74

Open MarcAntoine-Arnaud opened 6 years ago

MarcAntoine-Arnaud commented 6 years ago

Trying to use the library (on file who made 80Mo), I get a file with 81677962 bytes which become after the download to a size of 81969152.

I have take a look on the difference, and I found some additional bytes on 0x0A which was converted to 0x0D 0x0A. Do you have any idea of the issue ?

MarcAntoine-Arnaud commented 6 years ago

Just a remark, I obtain similar result using simple_retr or retr methods.

MarcAntoine-Arnaud commented 6 years ago

I made an another test on a small file (296164 and I got 308048). source look like:

00000000  ef bb bf 57 45 42 56 54  54 0d 0a 0d 0a 30 30 3a  |...WEBVTT....00:|
00000010  30 30 3a 30 30 2e 30 30  30 20 2d 2d 3e 20 30 30  |00:00.000 --> 00|
00000020  3a 30 30 3a 30 38 2e 32  34 30 0d 0a 2d 20 44 2e  |:00:08.240..- D.

and I wrote:

00000000  ef bb bf 57 45 42 56 54  54 0d 0d 0a 0d 0d 0a 30  |...WEBVTT......0|
00000010  30 3a 30 30 3a 30 30 2e  30 30 30 20 2d 2d 3e 20  |0:00:00.000 --> |
00000020  30 30 3a 30 30 3a 30 38  2e 32 34 30 0d 0d 0a 2d  |00:00:08.240...-|
MarcAntoine-Arnaud commented 6 years ago

Changing the unit test test data\n with "test data\nmore and more\n\nTHE END." will show you the problem. I got: [116, 101, 115, 116, 32, 100, 97, 116, 97, 13, 10, 109, 111, 114, 101, 32, 97, 110, 100, 32, 109, 111, 114, 101, 13, 10, 13, 10, 84, 72, 69, 32, 69, 78, 68, 46, 13, 10], instead of: [116, 101, 115, 116, 32, 100, 97, 116, 97, 10, 109, 111, 114, 101, 32, 97, 110, 100, 32, 109, 111, 114, 101, 10, 10, 84, 72, 69, 32, 69, 78, 68, 46]

igorivaniuk commented 6 years ago

@MarcAntoine-Arnaud have same problem set transfer_type to FileType::Binary helps

ftp_stream.transfer_type(FileType::Binary);

https://users.rust-lang.org/t/solved-ftp-upload-any-file/7107/4

vlourme commented 1 year ago

This should be included in README (or examples), I got stuck 2 hours trying to understand why my .gz file could not decompress.