]> sjero.net Git - wget/commitdiff
[svn] Don't clobber the file when -c is specified and the first attempt
authorhniksic <devnull@localhost>
Tue, 17 May 2005 12:53:08 +0000 (05:53 -0700)
committerhniksic <devnull@localhost>
Tue, 17 May 2005 12:53:08 +0000 (05:53 -0700)
to retrieve the file fails.

src/ChangeLog
src/ftp.c

index 10554461521442c204c2720a62a0260bb2d18f6f..9e3d845f54f88eec9d2014eebbba1713f63b849a 100644 (file)
@@ -1,5 +1,7 @@
 2005-05-17  Hrvoje Niksic  <hniksic@xemacs.org>
 
+       * ftp.c (ftp_loop_internal): Same here.
+
        * http.c (http_loop): Don't clobber the file when -c is specified
        and the first attempt to retrieve the file fails.
 
index afc4726665c84001e0963e99b03ca21ee7c0a3fb..9609f90c954c4b050cb988b0c00c7a844b4285aa 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1158,13 +1158,17 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
        }
 
       /* Decide whether or not to restart.  */
-      restval = 0;
-      if (count > 1)
-       restval = len;          /* start where the previous run left off */
-      else if (opt.always_rest
-              && stat (locf, &st) == 0
-              && S_ISREG (st.st_mode))
+      if (opt.always_rest
+         && stat (locf, &st) == 0
+         && S_ISREG (st.st_mode))
+       /* When -c is used, continue from on-disk size.  (Can't use
+          hstat.len even if count>1 because we don't want a failed
+          first attempt to clobber existing data.)  */
        restval = st.st_size;
+      else if (count > 1)
+       restval = len;          /* start where the previous run left off */
+      else
+       restval = 0;
 
       /* Get the current time string.  */
       tms = time_str (NULL);