]> sjero.net Git - wget/commitdiff
[svn] Refuse to download files from scratch if `-c' is used and the server
authorhniksic <devnull@localhost>
Sun, 29 Apr 2001 14:24:45 +0000 (07:24 -0700)
committerhniksic <devnull@localhost>
Sun, 29 Apr 2001 14:24:45 +0000 (07:24 -0700)
doesn't support REST only for existing *and non-empty* files.
Published in <sxsae4zg4zc.fsf@florida.arsdigita.de>.

src/ChangeLog
src/ftp.c

index 29fd32fd6de4d69c3d38a86cddf964df7f1a7658..9fed7116e0c9a635c65dbd3106eacb6dcd96afb6 100644 (file)
@@ -1,3 +1,8 @@
+2001-04-29  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * ftp.c (ftp_loop_internal): Don't set NO_TRUNCATE if the file is
+       empty.
+
 2001-04-29  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * main.c (main): Make `--cookies' respect its argument.
index 8f80e42407d3dc6821893c68e6421b4c29796935..a3565f9a46934ff4899d9bd15a8f2add8682ac83 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -989,7 +989,7 @@ Error in server response, closing control connection.\n"));
 static uerr_t
 ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
 {
-  int count, orig_lp, no_truncate;
+  int count, orig_lp;
   long restval, len;
   char *tms, *tmrate, *locf;
   uerr_t err;
@@ -1020,13 +1020,6 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
 
   orig_lp = con->cmd & LEAVE_PENDING ? 1 : 0;
 
-  /* In `-c' is used, check whether the file we're writing to exists
-     before we've done anything.  If so, we'll refuse to truncate it
-     if the server doesn't support continued downloads.  */
-  no_truncate = 0;
-  if (opt.always_rest)
-    no_truncate = file_exists_p (locf);
-
   /* THE loop.  */
   do
     {
@@ -1053,8 +1046,7 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
          else
            con->cmd |= DO_CWD;
        }
-      if (no_truncate)
-       con->cmd |= NO_TRUNCATE;
+
       /* Assume no restarting.  */
       restval = 0L;
       if ((count > 1 || opt.always_rest)
@@ -1062,6 +1054,14 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
          && file_exists_p (locf))
        if (stat (locf, &st) == 0 && S_ISREG (st.st_mode))
          restval = st.st_size;
+
+      /* In `-c' is used, check whether the file we're writing to
+        exists and is of non-zero length.  If so, we'll refuse to
+        truncate it if the server doesn't support continued
+        downloads.  */
+      if (opt.always_rest && restval > 0)
+       con->cmd |= NO_TRUNCATE;
+
       /* Get the current time string.  */
       tms = time_str (NULL);
       /* Print fetch message, if opt.verbose.  */