]> sjero.net Git - wget/commitdiff
Fix an infinite loop with error message '<filename> has sprung into existence'
authorGiuseppe Scrivano <gscrivano@gnu.org>
Fri, 19 Nov 2010 16:14:21 +0000 (17:14 +0100)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Fri, 19 Nov 2010 16:14:21 +0000 (17:14 +0100)
src/ChangeLog
src/ftp.c
src/http.c

index ed09202506b1d3bd4561b6a9461ce6d58bea1d14..51abb4ce3cd5255a1bc341660718fec60e2ce56f 100644 (file)
@@ -1,3 +1,14 @@
+2010-11-19  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * fttp.c (getftp): Accept new argument `count'.  When `count' is
+       bigger than zero, assume the file can be overwritten.
+       (ftp_loop_internal): Pass new argument `count' to `getftp'.
+
+       * http.c (gethttp): Accept new argument `count'.  When `count' is
+       bigger than zero, assume the file can be overwritten.
+       (http_loop): Pass new argument `count' to `gethttp'.
+       Reported by: Evgeny Kapun <abacabadabacaba@gmail.com>.
+
 2010-08-08  Reza Snowdon <vivi@mage.me.uk>
 
        * main.c (main): inserted 'defaults'.
index 42884d453a53635f13ca7c84a51b1a3013197cfb..8dddeed89cba85e1d83db44562c3a9c208edf059 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -241,7 +241,7 @@ static uerr_t ftp_get_listing (struct url *, ccon *, struct fileinfo **);
    and closes the control connection in case of error.  */
 static uerr_t
 getftp (struct url *u, wgint passed_expected_bytes, wgint *qtyread,
-        wgint restval, ccon *con)
+        wgint restval, ccon *con, int count)
 {
   int csock, dtsock, local_sock, res;
   uerr_t err = RETROK;          /* appease the compiler */
@@ -1172,7 +1172,7 @@ Error in server response, closing control connection.\n"));
 #endif /* def __VMS [else] */
         }
       else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct
-               || opt.output_document)
+               || opt.output_document || count > 0)
         {        
          if (opt.unlink && file_exists_p (con->target))
            {
@@ -1488,7 +1488,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
         len = f->size;
       else
         len = 0;
-      err = getftp (u, len, &qtyread, restval, con);
+      err = getftp (u, len, &qtyread, restval, con, count);
 
       if (con->csock == -1)
         con->st &= ~DONE_CWD;
index b34e57d0aa6cb0a2ba96df1db76b4804bab8e3a4..a0e41cac01791916e0561d2809c0928b22e1b47a 100644 (file)
@@ -1494,7 +1494,7 @@ free_hstat (struct http_stat *hs)
    server, and u->url will be requested.  */
 static uerr_t
 gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
-         struct iri *iri)
+         struct iri *iri, int count)
 {
   struct request *req;
 
@@ -2479,7 +2479,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
           fp = fopen (hs->local_file, "ab");
 #endif /* def __VMS [else] */
         }
-      else if (ALLOW_CLOBBER)
+      else if (ALLOW_CLOBBER || count > 0)
         {
          if (opt.unlink && file_exists_p (hs->local_file))
            {
@@ -2756,7 +2756,7 @@ Spider mode enabled. Check if remote file exists.\n"));
         *dt &= ~SEND_NOCACHE;
 
       /* Try fetching the document, or at least its head.  */
-      err = gethttp (u, &hstat, dt, proxy, iri);
+      err = gethttp (u, &hstat, dt, proxy, iri, count);
 
       /* Time?  */
       tms = datetime_str (time (NULL));