]> sjero.net Git - wget/commitdiff
[svn] Make `-c' and `-O' work together.
authorhniksic <devnull@localhost>
Tue, 3 Apr 2001 12:24:49 +0000 (05:24 -0700)
committerhniksic <devnull@localhost>
Tue, 3 Apr 2001 12:24:49 +0000 (05:24 -0700)
Published in <sxsitkmgokh.fsf@florida.arsdigita.de>.

src/ChangeLog
src/ftp.c
src/http.c
src/main.c

index 99709be50a55400d199f31e497812c39bdb04b83..d03d40ae77cb0fd037643f74d0ebece5177289d5 100644 (file)
@@ -1,3 +1,10 @@
+2001-04-02  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * http.c (http_loop): Ditto.
+
+       * ftp.c (ftp_loop_internal): Made the check whether to continue
+       retrieval `-O'-friendly.
+
 2001-04-02  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * netrc.c (parse_netrc): Don't trim the line endings explicitly;
index 0cdbcc1d18a1c5ef313fb10a77672b2802d4eeba..e9b686097cd28c3c980c7f6c9d60cfa4de60fee8 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -825,6 +825,9 @@ Error in server response, closing control connection.\n"));
          /* This will silently fail for streams that don't correspond
             to regular files, but that's OK.  */
          rewind (fp);
+         /* ftruncate is needed because opt.dfp is opened in append
+            mode if opt.always_rest is set.  */
+         ftruncate (fileno (fp), 0);
          clearerr (fp);
        }
     }
@@ -1033,8 +1036,8 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
       restval = 0L;
       if ((count > 1 || opt.always_rest)
          && !(con->cmd & DO_LIST)
-         && file_exists_p (u->local))
-       if (stat (u->local, &st) == 0)
+         && file_exists_p (locf))
+       if (stat (locf, &st) == 0 && S_ISREG (st.st_mode))
          restval = st.st_size;
       /* Get the current time string.  */
       tms = time_str (NULL);
index 4c65d6774d16201ebb731b463845409cd6262a1b..7c40d060092a42a150334716c4341d49fceb28ad 100644 (file)
@@ -1305,6 +1305,9 @@ Accept: %s\r\n\
          /* This will silently fail for streams that don't correspond
             to regular files, but that's OK.  */
          rewind (fp);
+         /* ftruncate is needed because opt.dfp is opened in append
+            mode if opt.always_rest is set.  */
+         ftruncate (fileno (fp), 0);
          clearerr (fp);
        }
     }
@@ -1487,8 +1490,8 @@ File `%s' already there, will not retrieve.\n"), u->local);
       hstat.restval = 0L;
       /* Decide whether or not to restart.  */
       if (((count > 1 && (*dt & ACCEPTRANGES)) || opt.always_rest)
-         && file_exists_p (u->local))
-       if (stat (u->local, &st) == 0)
+         && file_exists_p (locf))
+       if (stat (locf, &st) == 0 && S_ISREG (st.st_mode))
          hstat.restval = st.st_size;
       /* Decide whether to send the no-cache directive.  */
       if (u->proxy && (count > 1 || (opt.proxy_cache == 0)))
index 1f5a88aabfddda521251fa24c02c4696d935034a..34277c4771405ce94ef622ba3084418bd644319e 100644 (file)
@@ -752,7 +752,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
       else
        {
          struct stat st;
-         opt.dfp = fopen (opt.output_document, "wb");
+         opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb");
          if (opt.dfp == NULL)
            {
              perror (opt.output_document);