commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp FTPClient.java
Date Fri, 20 Sep 2002 14:36:42 GMT
dfs         2002/09/20 07:36:42

  Modified:    net/src/java/org/apache/commons/net/ftp FTPClient.java
  Log:
  Submitted by: Tapan Karecha <tapan@india.hp.com>
  Reviewed by: dfs
  
  Applied patch for restarting FTP file transfers.  The offset was not
  being sent immediately before the data transfer command on account.
  The bug was apparently introduced in NetComponents when it was decided
  to always send a PORT command before each data transfer to avoid
  socket reuse problems on Windows.  Tapan Karecha detected the error
  and supplied this fix.
  
  Revision  Changes    Path
  1.4       +36 -1     jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/FTPClient.java
  
  Index: FTPClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/FTPClient.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FTPClient.java	29 Apr 2002 03:55:31 -0000	1.3
  +++ FTPClient.java	20 Sep 2002 14:36:42 -0000	1.4
  @@ -246,6 +246,7 @@
       private int __fileType, __fileFormat, __fileStructure, __fileTransferMode;
       private boolean __remoteVerificationEnabled;
       private FTPFileListParser __fileListParser;
  +    private long __restartOffset;
   
       /***
        * Default FTPClient constructor.  Creates a new FTPClient instance
  @@ -358,6 +359,12 @@
                   return null;
               }
   
  +            if ((__restartOffset > 0) && !restart(__restartOffset))
  +            {
  +                server.close();
  +                return null;
  +            }
  +
               if (!FTPReply.isPositivePreliminary(sendCommand(command, arg)))
               {
                   server.close();
  @@ -1548,10 +1555,38 @@
        * @exception IOException  If an I/O error occurs while either sending a
        *      command to the server or receiving a reply from the server.
        ***/
  -    public boolean restart(long offset) throws IOException
  +    private boolean restart(long offset) throws IOException
       {
  +        __restartOffset = 0;
           return FTPReply.isPositiveIntermediate(rest(Long.toString(offset)));
       }
  +
  +    /***
  +     * Sets the restart offset.  The restart command is sent to the server
  +     * only before sending the file transfer command.  When this is done,
  +     * the restart marker is reset to zero.
  +     * <p>
  +     * @param offset  The offset into the remote file at which to start the
  +     *           next file transfer.  This must be a value greater than or
  +     *           equal to zero.
  +     ***/
  +    public void setRestartOffset(long offset)
  +    {
  +        if (offset >= 0)
  +            __restartOffset = offset;
  +    }
  +
  +    /***
  +     * Fetches the restart offset.
  +     * <p>
  +     * @return offset  The offset into the remote file at which to start the
  +     *           next file transfer.
  +     ***/
  +    public long getRestartOffset()
  +    {
  +        return __restartOffset;
  +    }
  +
   
   
       /***
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message