mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Fix file-checking in FTP with --spider.
This commit is contained in:
parent
9fa15c310f
commit
da51f9b2c4
@ -1,3 +1,8 @@
|
|||||||
|
2008-05-15 Steven Schubiger <schubiger@gmail.com>
|
||||||
|
|
||||||
|
* ftp.c (getftp): Verify that the file actually exists in FTP, by
|
||||||
|
checking it against the listing.
|
||||||
|
|
||||||
2008-05-12 Micah Cowan <micah@cowan.name>
|
2008-05-12 Micah Cowan <micah@cowan.name>
|
||||||
|
|
||||||
* main.c (main): Downgrade "-N with -O" to a warning, and switch
|
* main.c (main): Downgrade "-N with -O" to a warning, and switch
|
||||||
|
35
src/ftp.c
35
src/ftp.c
@ -227,6 +227,8 @@ print_length (wgint size, wgint start, bool authoritative)
|
|||||||
logputs (LOG_VERBOSE, !authoritative ? _(" (unauthoritative)\n") : "\n");
|
logputs (LOG_VERBOSE, !authoritative ? _(" (unauthoritative)\n") : "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uerr_t ftp_get_listing (struct url *, ccon *, struct fileinfo **);
|
||||||
|
|
||||||
/* Retrieves a file with denoted parameters through opening an FTP
|
/* Retrieves a file with denoted parameters through opening an FTP
|
||||||
connection to the server. It always closes the data connection,
|
connection to the server. It always closes the data connection,
|
||||||
and closes the control connection in case of error. */
|
and closes the control connection in case of error. */
|
||||||
@ -776,12 +778,37 @@ Error in server response, closing control connection.\n"));
|
|||||||
|
|
||||||
if (cmd & DO_RETR)
|
if (cmd & DO_RETR)
|
||||||
{
|
{
|
||||||
/* If we're in spider mode, don't really retrieve anything. The
|
/* If we're in spider mode, don't really retrieve anything except
|
||||||
fact that we got to this point should be proof enough that
|
the directory listing and verify whether the given "file" exists. */
|
||||||
the file exists, vaguely akin to HTTP's concept of a "HEAD"
|
|
||||||
request. */
|
|
||||||
if (opt.spider)
|
if (opt.spider)
|
||||||
{
|
{
|
||||||
|
bool exists = false;
|
||||||
|
uerr_t res;
|
||||||
|
struct fileinfo *f;
|
||||||
|
res = ftp_get_listing (u, con, &f);
|
||||||
|
/* Set the DO_RETR command flag again, because it gets unset when
|
||||||
|
calling ftp_get_listing() and would otherwise cause an assertion
|
||||||
|
failure earlier on when this function gets repeatedly called
|
||||||
|
(e.g., when recursing). */
|
||||||
|
con->cmd |= DO_RETR;
|
||||||
|
if (res == RETROK)
|
||||||
|
{
|
||||||
|
while (f)
|
||||||
|
{
|
||||||
|
if (!strcmp (f->name, u->file))
|
||||||
|
{
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
f = f->next;
|
||||||
|
}
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
logputs (LOG_VERBOSE, "\n");
|
||||||
|
logprintf (LOG_NOTQUIET, _("No such file `%s'.\n"),
|
||||||
|
escnonprint (u->file));
|
||||||
|
}
|
||||||
|
}
|
||||||
fd_close (csock);
|
fd_close (csock);
|
||||||
con->csock = -1;
|
con->csock = -1;
|
||||||
fd_close (dtsock);
|
fd_close (dtsock);
|
||||||
|
Loading…
Reference in New Issue
Block a user