ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
Date Wed, 22 May 2002 20:22:53 GMT
stevel      02/05/22 13:22:53

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net Tag:
                        ANT_15_BRANCH FTP.java
  Log:
  PR 9320; not handling mkdir errors consistently. Fixed by refactoring the working routine
into its own method, calling from both places.
  
  This is going to be a dog to add an explicit test for.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.21.2.1  +18 -20    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.21
  retrieving revision 1.21.2.1
  diff -u -r1.21 -r1.21.2.1
  --- FTP.java	15 Apr 2002 14:56:33 -0000	1.21
  +++ FTP.java	22 May 2002 20:22:52 -0000	1.21.2.1
  @@ -611,17 +611,8 @@
               if (!dirCache.contains(dir)) {
                   log("creating remote directory " + resolveFile(dir.getPath()),
                       Project.MSG_VERBOSE);
  -                ftp.makeDirectory(resolveFile(dir.getPath()));
  -                // Both codes 550 and 553 can be produced by FTP Servers
  -                //  to indicate that an attempt to create a directory has
  -                //  failed because the directory already exists.
  -                int result = ftp.getReplyCode();
  -
  -                if (!FTPReply.isPositiveCompletion(result) &&
  -                    (result != 550) && (result != 553) &&
  -                    !ignoreNoncriticalErrors) {
  -                    throw new BuildException("could not create directory: " +
  -                        ftp.getReplyString());
  +                if(!ftp.makeDirectory(resolveFile(dir.getPath()))) {
  +                    handleMkDirFailure(ftp);
                   }
                   dirCache.addElement(dir);
               }
  @@ -880,15 +871,7 @@
               // codes 521, 550 and 553 can be produced by FTP Servers
               //  to indicate that an attempt to create a directory has
               //  failed because the directory already exists.
  -
  -            int rc = ftp.getReplyCode();
  -
  -            if (!(ignoreNoncriticalErrors
  -                 && (rc == 550 || rc == 553 || rc == 521))) {
  -                throw new BuildException("could not create directory: " +
  -                    ftp.getReplyString());
  -            }
  -
  +            handleMkDirFailure(ftp);
               if (verbose) {
                   log("directory already exists");
               }
  @@ -899,6 +882,21 @@
           }
       }
   
  +    /**
  +     * look at the response for a failed mkdir action, decide whether
  +     * it matters or not. If it does, we throw an exception
  +     * @param ftp current ftp connection
  +     * @throws BuildException if this is an error to signal
  +     */
  +    private void handleMkDirFailure(FTPClient ftp) 
  +            throws BuildException {
  +        int rc=ftp.getReplyCode();
  +        if (!(ignoreNoncriticalErrors
  +             && (rc == 550 || rc == 553 || rc == 521))) {
  +            throw new BuildException("could not create directory: " +
  +                ftp.getReplyString());
  +        }
  +    }
   
       /** Runs the task.  */
       public void execute()
  
  
  

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


Mime
View raw message