]> sjero.net Git - wget/blobdiff - src/ftp.c
[svn] --delete-after wasn't implemented for files retrieved by FTP or corresponding to
[wget] / src / ftp.c
index 6d549a3e1e30932a6a45839780c1db37a4bae1eb..ab70114b33220b00005bc22e428d730bbeed8005 100644 (file)
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -989,13 +989,42 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
                 tms, tmrate, locf, len);
       logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n",
                 tms, u->url, len, locf, count);
-      /* Do not count listings among the downloaded stuff, since they
-        will get deleted anyway.  */
-      if (!(con->cmd & DO_LIST))
+
+      if ((con->cmd & DO_LIST))
+       /* This is a directory listing file. */
+       {
+         if (!opt.remove_listing)
+           /* --dont-remove-listing was specified, so do count this towards the
+              number of bytes and files downloaded. */
+           {
+             opt.downloaded += len;
+             opt.numurls++;
+           }
+
+         /* Deletion of listing files is not controlled by --delete-after, but
+            by the more specific option --dont-remove-listing, and the code
+            to do this deletion is in another function. */
+       }
+      else
+       /* This is not a directory listing file. */
        {
-         ++opt.numurls;
+         /* Unlike directory listing files, don't pretend normal files weren't
+            downloaded if they're going to be deleted.  People seeding proxies,
+            for instance, may want to know how many bytes and files they've
+            downloaded through it. */
          opt.downloaded += len;
+         opt.numurls++;
+
+         if (opt.delete_after)
+           {
+             DEBUGP (("Removing file due to --delete-after in"
+                      " ftp_loop_internal():\n"));
+             logprintf (LOG_VERBOSE, _("Removing %s.\n"), locf);
+             if (unlink (locf))
+               logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
+           }
        }
+      
       /* Restore the original leave-pendingness.  */
       if (orig_lp)
        con->cmd |= LEAVE_PENDING;