I have found that -k option does not work on downloaded ftp files.

The key problem seems to be that register_download is never called on
ftp files downloaded as local_file is never set for calls to ftp_loop
like they are on calls to http_loop.

So, I added local_file as a parameter to ftp_loop and used con.target
within the ftp_loop function in order to save this information such
that it get's retistered so it will be rewritten.

The diffs are for files ftp.c, ftp.h, and retr.c.

I have not studied the impact on further logic on the change.

The one thing I am unsure of is the following if statement
(line 428 of wget 1.8.2's retr.c file):

      if (redirections && local_file && u->scheme == SCHEME_FTP)

If local_file here relied on a setting in from prior logic before the
ftp_loop call, then that value would be gone, and this logic would
therefore would likely not work as intended.  

Your input on these changes would be appreciated.  All I ask is that if
this change be used that I get a mention in the ChangeLog.

I'm still looking into any further impacts these code changes would
have, but initially it looks OK.

Thanks,

  -- Curt
  
Here are the diffs:

*** ftp.c       Fri May 17 23:05:16 2002
--- ../../wget-1.8.2.cw/src/ftp.c       Sat Oct 19 13:14:06 2002
***************
*** 1637,1643 ****
     of URL.  Inherently, its capabilities are limited on what can be
     encoded into a URL.  */
  uerr_t
! ftp_loop (struct url *u, int *dt)
  {
    ccon con;                   /* FTP connection */
    uerr_t res;
--- 1637,1643 ----
     of URL.  Inherently, its capabilities are limited on what can be
     encoded into a URL.  */
  uerr_t
! ftp_loop (struct url *u, char **local_file, int *dt)
  {
    ccon con;                   /* FTP connection */
    uerr_t res;
***************
*** 1716,1723 ****
      CLOSE (RBUF_FD (&con.rbuf));
    FREE_MAYBE (con.id);
    con.id = NULL;
!   FREE_MAYBE (con.target);
!   con.target = NULL;
    return res;
  }
  
--- 1716,1730 ----
      CLOSE (RBUF_FD (&con.rbuf));
    FREE_MAYBE (con.id);
    con.id = NULL;
!   if (res == RETROK)
!   {
!     *local_file = con.target;
!   }
!   else
!   {
!     FREE_MAYBE (con.target);
!     con.target = NULL;
!   }
    return res;
  }


*** ftp.h       Sat May 18 23:04:53 2002
--- ../../wget-1.8.2.cw/src/ftp.h       Sat Oct 19 13:13:36 2002
***************
*** 109,115 ****
  };
  
  struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
! uerr_t ftp_loop PARAMS ((struct url *, int *));
  
  uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));
  
--- 109,115 ----
  };
  
  struct fileinfo *ftp_parse_ls PARAMS ((const char *, const enum stype));
! uerr_t ftp_loop PARAMS ((struct url *, char **, int *));
  
  uerr_t ftp_index PARAMS ((const char *, struct url *, struct fileinfo *));



*** retr.c      Fri May 17 23:05:21 2002
--- ../../wget-1.8.2.cw/src/retr.c      Sat Oct 19 12:58:34 2002
***************
*** 418,424 ****
        int oldrec = opt.recursive;
        if (redirections)
        opt.recursive = 0;
!       result = ftp_loop (u, dt);
        opt.recursive = oldrec;
  
        /* There is a possibility of having HTTP being redirected to
--- 418,424 ----
        int oldrec = opt.recursive;
        if (redirections)
        opt.recursive = 0;
!       result = ftp_loop (u, &local_file, dt);
        opt.recursive = oldrec;
  
        /* There is a possibility of having HTTP being redirected to

Curtis H. Wilbar Jr.
Hawk Mountain Networks
[EMAIL PROTECTED]


Reply via email to