From: hniksic Date: Sun, 29 Apr 2001 14:24:45 +0000 (-0700) Subject: [svn] Refuse to download files from scratch if `-c' is used and the server X-Git-Tag: v1.13~2152 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=3973f20a45afba6bccef49e098ff195041c2be09 [svn] Refuse to download files from scratch if `-c' is used and the server doesn't support REST only for existing *and non-empty* files. Published in . --- diff --git a/src/ChangeLog b/src/ChangeLog index 29fd32fd..9fed7116 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-04-29 Hrvoje Niksic + + * ftp.c (ftp_loop_internal): Don't set NO_TRUNCATE if the file is + empty. + 2001-04-29 Hrvoje Niksic * main.c (main): Make `--cookies' respect its argument. diff --git a/src/ftp.c b/src/ftp.c index 8f80e424..a3565f9a 100644 --- 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. */