]> sjero.net Git - wget/commitdiff
[svn] Don't clobber the file when -c fails in the first attempt.
authorhniksic <devnull@localhost>
Tue, 17 May 2005 09:01:31 +0000 (02:01 -0700)
committerhniksic <devnull@localhost>
Tue, 17 May 2005 09:01:31 +0000 (02:01 -0700)
src/ChangeLog
src/http.c

index 6ffdb2c066c63f68858b559988b6633083e9d7c3..10554461521442c204c2720a62a0260bb2d18f6f 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-17  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * http.c (http_loop): Don't clobber the file when -c is specified
+       and the first attempt to retrieve the file fails.
+
 2005-05-16  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * openssl.c (ssl_check_certificate): Print all issues with a
index 3a2f908ebd94f94dfbff11bf0881ceb37dfd89b7..d549012cb1e3c33d5471bd9fb58baeed348717f4 100644 (file)
@@ -2141,13 +2141,18 @@ File `%s' already there, will not retrieve.\n"), *hstat.local_file);
        *dt &= ~HEAD_ONLY;
 
       /* Decide whether or not to restart.  */
-      hstat.restval = 0;
-      if (count > 1)
-       hstat.restval = hstat.len; /* continue where we 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.)  */
        hstat.restval = st.st_size;
+      else if (count > 1)
+       /* otherwise, continue where the previous try left off */
+       hstat.restval = hstat.len;
+      else
+       hstat.restval = 0;
 
       /* Decide whether to send the no-cache directive.  We send it in
         two cases: