Jozua <jo...@sparky.za.net> writes: > Hi. > > When continuing a ftp download, an incorrect value is used for the > total file size. > The SIZE command returns the correct size, but the value used comes > from the response to the RETR command, which (at least in this case) > is the number of bytes remaining after REST. (See below for more > info). > > The bug seems to be introduced by the line : > expected_bytes = ftp_expected_bytes (ftp_last_respline); > in src/ftp.c (line 1022) > > Commenting out that line seems to fix the bug, but i have no idea how > it will affect things if the server does not support the SIZE command.
Thanks for your report. I am going to apply this patch instead, it seems safer than consider just one value between RETR and SIZE. I have tested it with a couple of different FTP servers and seems to work as expected. Cheers, Giuseppe === modified file 'src/ftp.c' --- src/ftp.c 2010-05-08 19:56:15 +0000 +++ src/ftp.c 2010-07-13 19:14:41 +0000 @@ -63,6 +63,8 @@ #define LIST_FILENAME ".listing" #endif +#define max(a, b) ((a > b) ? (a) : (b)) + typedef struct { int st; /* connection status */ @@ -1019,7 +1021,8 @@ if (!opt.server_response) logputs (LOG_VERBOSE, _("done.\n")); - expected_bytes = ftp_expected_bytes (ftp_last_respline); + + expected_bytes = max (expected_bytes, ftp_expected_bytes (ftp_last_respline)); } /* do retrieve */ if (cmd & DO_LIST) @@ -1065,7 +1068,7 @@ } if (!opt.server_response) logputs (LOG_VERBOSE, _("done.\n")); - expected_bytes = ftp_expected_bytes (ftp_last_respline); + expected_bytes = max (expected_bytes, ftp_expected_bytes (ftp_last_respline)); } /* cmd & DO_LIST */ if (!(cmd & (DO_LIST | DO_RETR)) || (opt.spider && !(cmd & DO_LIST)))