1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[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 <sxsae4zg4zc.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2001-04-29 07:24:45 -07:00
parent d73ea12fd1
commit 3973f20a45
2 changed files with 15 additions and 10 deletions

View 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.

View File

@ -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. */