mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Fix timestamping and continue behaviour with ftp protocol.
* src/ftp.c (ftp_loop_internal): Add option `force_full_retrieve' that force to retrieve full file. (ftp_retrieve_list): Pass `true' as `force_full_retrieve' option to `ftp_loop_internal' if we want to download file with newer timestamp than local copy.
This commit is contained in:
parent
3765a1b266
commit
0e6d6ca963
21
src/ftp.c
21
src/ftp.c
@ -1540,7 +1540,8 @@ Error in server response, closing control connection.\n"));
|
|||||||
This loop either gets commands from con, or (if ON_YOUR_OWN is
|
This loop either gets commands from con, or (if ON_YOUR_OWN is
|
||||||
set), makes them up to retrieve the file given by the URL. */
|
set), makes them up to retrieve the file given by the URL. */
|
||||||
static uerr_t
|
static uerr_t
|
||||||
ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_file)
|
ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_file,
|
||||||
|
bool force_full_retrieve)
|
||||||
{
|
{
|
||||||
int count, orig_lp;
|
int count, orig_lp;
|
||||||
wgint restval, len = 0, qtyread = 0;
|
wgint restval, len = 0, qtyread = 0;
|
||||||
@ -1642,6 +1643,8 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
|||||||
/* Decide whether or not to restart. */
|
/* Decide whether or not to restart. */
|
||||||
if (con->cmd & DO_LIST)
|
if (con->cmd & DO_LIST)
|
||||||
restval = 0;
|
restval = 0;
|
||||||
|
else if (force_full_retrieve)
|
||||||
|
restval = 0;
|
||||||
else if (opt.start_pos >= 0)
|
else if (opt.start_pos >= 0)
|
||||||
restval = opt.start_pos;
|
restval = opt.start_pos;
|
||||||
else if (opt.always_rest
|
else if (opt.always_rest
|
||||||
@ -1865,7 +1868,7 @@ ftp_get_listing (struct url *u, ccon *con, struct fileinfo **f)
|
|||||||
|
|
||||||
con->target = xstrdup (lf);
|
con->target = xstrdup (lf);
|
||||||
xfree (lf);
|
xfree (lf);
|
||||||
err = ftp_loop_internal (u, NULL, con, NULL);
|
err = ftp_loop_internal (u, NULL, con, NULL, false);
|
||||||
lf = xstrdup (con->target);
|
lf = xstrdup (con->target);
|
||||||
xfree (con->target);
|
xfree (con->target);
|
||||||
con->target = old_target;
|
con->target = old_target;
|
||||||
@ -1910,6 +1913,7 @@ ftp_retrieve_list (struct url *u, struct fileinfo *f, ccon *con)
|
|||||||
time_t tml;
|
time_t tml;
|
||||||
bool dlthis; /* Download this (file). */
|
bool dlthis; /* Download this (file). */
|
||||||
const char *actual_target = NULL;
|
const char *actual_target = NULL;
|
||||||
|
bool force_full_retrieve = false;
|
||||||
|
|
||||||
/* Increase the depth. */
|
/* Increase the depth. */
|
||||||
++depth;
|
++depth;
|
||||||
@ -1989,9 +1993,10 @@ ftp_retrieve_list (struct url *u, struct fileinfo *f, ccon *con)
|
|||||||
Remote file no newer than local file %s -- not retrieving.\n"), quote (con->target));
|
Remote file no newer than local file %s -- not retrieving.\n"), quote (con->target));
|
||||||
dlthis = false;
|
dlthis = false;
|
||||||
}
|
}
|
||||||
else if (eq_size)
|
else if (f->tstamp > tml)
|
||||||
{
|
{
|
||||||
/* Remote file is newer or sizes cannot be matched */
|
/* Remote file is newer */
|
||||||
|
force_full_retrieve = true;
|
||||||
logprintf (LOG_VERBOSE, _("\
|
logprintf (LOG_VERBOSE, _("\
|
||||||
Remote file is newer than local file %s -- retrieving.\n\n"),
|
Remote file is newer than local file %s -- retrieving.\n\n"),
|
||||||
quote (con->target));
|
quote (con->target));
|
||||||
@ -2060,7 +2065,7 @@ Already have correct symlink %s -> %s\n\n"),
|
|||||||
else /* opt.retr_symlinks */
|
else /* opt.retr_symlinks */
|
||||||
{
|
{
|
||||||
if (dlthis)
|
if (dlthis)
|
||||||
err = ftp_loop_internal (u, f, con, NULL);
|
err = ftp_loop_internal (u, f, con, NULL, force_full_retrieve);
|
||||||
} /* opt.retr_symlinks */
|
} /* opt.retr_symlinks */
|
||||||
break;
|
break;
|
||||||
case FT_DIRECTORY:
|
case FT_DIRECTORY:
|
||||||
@ -2071,7 +2076,7 @@ Already have correct symlink %s -> %s\n\n"),
|
|||||||
case FT_PLAINFILE:
|
case FT_PLAINFILE:
|
||||||
/* Call the retrieve loop. */
|
/* Call the retrieve loop. */
|
||||||
if (dlthis)
|
if (dlthis)
|
||||||
err = ftp_loop_internal (u, f, con, NULL);
|
err = ftp_loop_internal (u, f, con, NULL, force_full_retrieve);
|
||||||
break;
|
break;
|
||||||
case FT_UNKNOWN:
|
case FT_UNKNOWN:
|
||||||
logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
|
logprintf (LOG_NOTQUIET, _("%s: unknown/unsupported file type.\n"),
|
||||||
@ -2377,7 +2382,7 @@ ftp_retrieve_glob (struct url *u, ccon *con, int action)
|
|||||||
{
|
{
|
||||||
/* Let's try retrieving it anyway. */
|
/* Let's try retrieving it anyway. */
|
||||||
con->st |= ON_YOUR_OWN;
|
con->st |= ON_YOUR_OWN;
|
||||||
res = ftp_loop_internal (u, NULL, con, NULL);
|
res = ftp_loop_internal (u, NULL, con, NULL, false);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2477,7 +2482,7 @@ ftp_loop (struct url *u, char **local_file, int *dt, struct url *proxy,
|
|||||||
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
|
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = ftp_loop_internal (u, NULL, &con, local_file);
|
res = ftp_loop_internal (u, NULL, &con, local_file, false);
|
||||||
}
|
}
|
||||||
if (res == FTPOK)
|
if (res == FTPOK)
|
||||||
res = RETROK;
|
res = RETROK;
|
||||||
|
Loading…
Reference in New Issue
Block a user