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

Merging heads.

This commit is contained in:
Micah Cowan 2008-05-15 22:36:20 -07:00
commit d78cd8d8f8
5 changed files with 56 additions and 9 deletions

View File

@ -2,6 +2,11 @@
* NEWS: Entry for --ask-password.
2008-05-14 Joao Ferreira <joao@joaoff.com>
* src/main.c, src/http.c, src/ftp.c: -nc is now working in
conjunction with '-O file'.
2008-05-12 Micah Cowan <micah@cowan.name>
* NEWS: Translations and -N/-O.

View File

@ -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-15 Micah Cowan <micah@cowan.name>
* main.c (prompt_for_password): Use the quote module.

View File

@ -227,6 +227,8 @@ print_length (wgint size, wgint start, bool authoritative)
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
connection to the server. It always closes the data connection,
and closes the control connection in case of error. */
@ -779,12 +781,37 @@ Error in server response, closing control connection.\n"));
if (cmd & DO_RETR)
{
/* If we're in spider mode, don't really retrieve anything. The
fact that we got to this point should be proof enough that
the file exists, vaguely akin to HTTP's concept of a "HEAD"
request. */
/* If we're in spider mode, don't really retrieve anything except
the directory listing and verify whether the given "file" exists. */
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);
con->csock = -1;
fd_close (dtsock);
@ -1096,7 +1123,9 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
if (!con->target)
con->target = url_file_name (u);
if (opt.noclobber && file_exists_p (con->target))
/* If the output_document was given, then this check was already done and
the file didn't exist. Hence the !opt.output_document */
if (opt.noclobber && !opt.output_document && file_exists_p (con->target))
{
logprintf (LOG_VERBOSE,
_("File %s already there; not retrieving.\n"), quote (con->target));

View File

@ -1823,10 +1823,11 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
/* TODO: perform this check only once. */
if (!hs->existence_checked && file_exists_p (hs->local_file))
{
if (opt.noclobber)
if (opt.noclobber && !opt.output_document)
{
/* If opt.noclobber is turned on and file already exists, do not
retrieve the file */
retrieve the file. But if the output_document was given, then this
test was already done and the file didn't exist. Hence the !opt.output_document */
logprintf (LOG_VERBOSE, _("\
File %s already there; not retrieving.\n\n"), quote (hs->local_file));
/* If the file is there, we suppose it's retrieved OK. */
@ -2376,10 +2377,11 @@ http_loop (struct url *u, char **newloc, char **local_file, const char *referer,
/* TODO: Ick! This code is now in both gethttp and http_loop, and is
* screaming for some refactoring. */
if (got_name && file_exists_p (hstat.local_file) && opt.noclobber)
if (got_name && file_exists_p (hstat.local_file) && opt.noclobber && !opt.output_document)
{
/* If opt.noclobber is turned on and file already exists, do not
retrieve the file */
retrieve the file. But if the output_document was given, then this
test was already done and the file didn't exist. Hence the !opt.output_document */
logprintf (LOG_VERBOSE, _("\
File %s already there; not retrieving.\n\n"),
quote (hstat.local_file));

View File

@ -920,6 +920,12 @@ WARNING: timestamping does nothing in combination with -O. See the manual\n\
for details.\n\n"));
opt.timestamping = false;
}
if (opt.noclobber && file_exists_p(opt.output_document))
{
/* Check if output file exists; if it does, exit. */
logprintf (LOG_VERBOSE, _("File `%s' already there; not retrieving.\n"), opt.output_document);
exit(1);
}
}
if (opt.ask_passwd && opt.passwd)