]> sjero.net Git - wget/blobdiff - src/ftp.c
Take the maximum value between RETR and SIZE bytes counts for the file size
[wget] / src / ftp.c
index 79b23b30205424918b6303b64159bd100d7ba2f0..c5ac83032aa596ad659bd9fa3b384db5669618a7 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1,6 +1,6 @@
 /* File Transfer Protocol support.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -63,6 +63,8 @@ as that of the covered work.  */
 #define LIST_FILENAME ".listing"
 #endif
 
+#define max(a, b) ((a > b) ? (a) : (b))
+
 typedef struct
 {
   int st;                       /* connection status */
@@ -1019,7 +1021,9 @@ Error in server response, closing control connection.\n"));
 
       if (!opt.server_response)
         logputs (LOG_VERBOSE, _("done.\n"));
-      expected_bytes = ftp_expected_bytes (ftp_last_respline);
+
+      expected_bytes = max (ftp_expected_bytes (ftp_last_respline),
+                            expected_bytes);
     } /* do retrieve */
 
   if (cmd & DO_LIST)
@@ -1065,7 +1069,8 @@ Error in server response, closing control connection.\n"));
         }
       if (!opt.server_response)
         logputs (LOG_VERBOSE, _("done.\n"));
-      expected_bytes = ftp_expected_bytes (ftp_last_respline);
+      expected_bytes = max (ftp_expected_bytes (ftp_last_respline),
+                            expected_bytes);
     } /* cmd & DO_LIST */
 
   if (!(cmd & (DO_LIST | DO_RETR)) || (opt.spider && !(cmd & DO_LIST)))