[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [PATCH] Simultaneous timestamping and continue with ftp
From: |
Nikolay Merinov |
Subject: |
[Bug-wget] [PATCH] Simultaneous timestamping and continue with ftp |
Date: |
Fri, 17 Apr 2015 23:54:49 +0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Hello,
Previously you created code for processing simultaneous options "-N" and
"-c" with HTTP protocol:
<https://lists.gnu.org/archive/html/bug-wget/2010-07/msg00025.html>
I attached patch with same changes for FTP.
---
Nikolay Merinov
>From dd947b5186c790281400b4239f850425ae8fde30 Mon Sep 17 00:00:00 2001
From: Nikolay Merinov <address@hidden>
Date: Fri, 17 Apr 2015 23:32:30 +0500
Subject: [PATCH] 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.
---
src/ftp.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/ftp.c b/src/ftp.c
index 1902242..68f1a33 100644
--- a/src/ftp.c
+++ b/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
set), makes them up to retrieve the file given by the URL. */
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;
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. */
if (con->cmd & DO_LIST)
restval = 0;
+ else if (force_full_retrieve)
+ restval = 0;
else if (opt.start_pos >= 0)
restval = opt.start_pos;
else if (opt.always_rest
@@ -1865,7 +1868,7 @@ ftp_get_listing (struct url *u, ccon *con, struct
fileinfo **f)
con->target = xstrdup (lf);
xfree (lf);
- err = ftp_loop_internal (u, NULL, con, NULL);
+ err = ftp_loop_internal (u, NULL, con, NULL, false);
lf = xstrdup (con->target);
xfree (con->target);
con->target = old_target;
@@ -1910,6 +1913,7 @@ ftp_retrieve_list (struct url *u, struct fileinfo *f,
ccon *con)
time_t tml;
bool dlthis; /* Download this (file). */
const char *actual_target = NULL;
+ bool force_full_retrieve = false;
/* Increase the 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));
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, _("\
Remote file is newer than local file %s -- retrieving.\n\n"),
quote (con->target));
@@ -2060,7 +2065,7 @@ Already have correct symlink %s -> %s\n\n"),
else /* opt.retr_symlinks */
{
if (dlthis)
- err = ftp_loop_internal (u, f, con, NULL);
+ err = ftp_loop_internal (u, f, con, NULL, force_full_retrieve);
} /* opt.retr_symlinks */
break;
case FT_DIRECTORY:
@@ -2071,7 +2076,7 @@ Already have correct symlink %s -> %s\n\n"),
case FT_PLAINFILE:
/* Call the retrieve loop. */
if (dlthis)
- err = ftp_loop_internal (u, f, con, NULL);
+ err = ftp_loop_internal (u, f, con, NULL, force_full_retrieve);
break;
case FT_UNKNOWN:
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. */
con->st |= ON_YOUR_OWN;
- res = ftp_loop_internal (u, NULL, con, NULL);
+ res = ftp_loop_internal (u, NULL, con, NULL, false);
return res;
}
@@ -2477,7 +2482,7 @@ ftp_loop (struct url *u, char **local_file, int *dt,
struct url *proxy,
ispattern ? GLOB_GLOBALL : GLOB_GETONE);
}
else
- res = ftp_loop_internal (u, NULL, &con, local_file);
+ res = ftp_loop_internal (u, NULL, &con, local_file, false);
}
if (res == FTPOK)
res = RETROK;
--
2.1.4
- [Bug-wget] [PATCH] Simultaneous timestamping and continue with ftp,
Nikolay Merinov <=