ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sco...@apache.org
Subject cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml
Date Sun, 22 May 2005 18:48:42 GMT
scohen      2005/05/22 11:48:42

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
               src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Add new timestampGranularity attribute to account for the typical case in PUT operations
where the client
  is HH:mm:ss and the ftp server is HH:mm.
  
  Revision  Changes    Path
  1.74      +56 -4     ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- FTP.java	21 May 2005 13:02:02 -0000	1.73
  +++ FTP.java	22 May 2005 18:48:42 -0000	1.74
  @@ -81,6 +81,11 @@
       protected static final int RM_DIR = 6;
       /** return code of ftp - not implemented in commons-net version 1.0 */
       private static final int CODE_521 = 521;
  +    
  +    /** adjust uptodate calculations where server timestamps are HH:mm and client's
  +     * are HH:mm:ss */
  +    private static final long GRANULARITY_MINUTE = 60000L;
  +    
       /** Default port for FTP */
       public static final int DEFAULT_FTP_PORT = 21;
   
  @@ -115,6 +120,8 @@
       private String serverLanguageCodeConfig = null;
       private String serverTimeZoneConfig = null;
       private String shortMonthNamesConfig = null;
  +    private String timestampGranularity = null;
  +    private long serverTimestampGranularity = 0L;
       private boolean isConfigurationSet = false;
   
       protected static final String[] ACTION_STRS = {
  @@ -1387,6 +1394,21 @@
           return shortMonthNamesConfig;
       }
       /**
  +     * @return Returns the timestampGranularity.
  +     */
  +    String getTimestampGranularity() {
  +        return timestampGranularity;
  +    }
  +    /**
  +     * @param timestampGranularity The timestampGranularity to set.
  +     */
  +    public void setTimestampGranularity(String timestampGranularity) {
  +        if (null == timestampGranularity || "".equals(timestampGranularity)) {
  +            return;
  +        }
  +        this.timestampGranularity = timestampGranularity;
  +     }
  +    /**
        * Checks to see that all required parameters are set.
        *
        * @throws BuildException if the configuration is not valid.
  @@ -1493,7 +1515,32 @@
                   for (int i = dsfiles.length - 1; i >= 0; i--) {
                       rmDir(ftp, dsfiles[i]);
                   }
  -            }   else {
  +            } else {
  +                if (this.newerOnly) {
  +	                if (action == SEND_FILES) {
  +	                    if ("NONE".equalsIgnoreCase(this.timestampGranularity)) 
  +	                    {
  +	                        this.serverTimestampGranularity = 0L;
  +	                    }
  +	                    else if ("MINUTE".equalsIgnoreCase(this.timestampGranularity)) 
  +	                    {
  +	                        this.serverTimestampGranularity = GRANULARITY_MINUTE;
  +	                    } 
  +	                    else 
  +	                    {
  +	                        this.serverTimestampGranularity = GRANULARITY_MINUTE;
  +	                    }
  +	                } else if (action == GET_FILES) {
  +	                    if ("MINUTE".equalsIgnoreCase(this.timestampGranularity)) 
  +	                    {
  +	                        this.serverTimestampGranularity = GRANULARITY_MINUTE;
  + 	                    }
  +	                    else 
  +	                    {
  +	                        this.serverTimestampGranularity = 0L;
  +	                    }
  +	                }
  +                }
                   for (int i = 0; i < dsfiles.length; i++) {
                       switch (action) {
                           case SEND_FILES:
  @@ -1749,11 +1796,16 @@
   
           long remoteTimestamp = files[0].getTimestamp().getTime().getTime();
           long localTimestamp = localFile.lastModified();
  -
           if (this.action == SEND_FILES) {
  -            return remoteTimestamp + timeDiffMillis >= localTimestamp;
  +            return remoteTimestamp 
  +            		+ this.timeDiffMillis 
  +            		+ this.serverTimestampGranularity 
  +            	>= localTimestamp;
           } else {
  -            return localTimestamp >= remoteTimestamp + timeDiffMillis;
  +            return localTimestamp 
  +            	>= remoteTimestamp 
  +                	+ this.timeDiffMillis
  +                	+ this.serverTimestampGranularity;
           }
       }
   
  
  
  
  1.10      +2 -3      ant/src/etc/testcases/taskdefs/optional/net/ftp.xml
  
  Index: ftp.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/net/ftp.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ftp.xml	22 May 2005 02:58:47 -0000	1.9
  +++ ftp.xml	22 May 2005 18:48:42 -0000	1.10
  @@ -142,10 +142,10 @@
   
       <target name="timed.test.put.older">
           <tstamp>
  -            <format property="five.minutes.older" pattern="${tstamp.format}" offset="-5"
unit="minute"/>
  +            <format property="one.minute.older" pattern="${tstamp.format}" offset="-60"
unit="second"/>
           </tstamp>
   
  -        <touch datetime="${five.minutes.older}" pattern="${tstamp.format}" verbose="true">
  +        <touch datetime="${one.minute.older}" pattern="${tstamp.format}" verbose="true">
               <fileset dir="${tmp.remote}">
                   <include name="A.timed"/>
               </fileset>
  @@ -156,7 +156,6 @@
               password="${ftp.password}"
               separator="${ftp.filesep}"
               remotedir="${tmp.remote}"
  -            timediffmillis="${server.timestamp.granularity.millis}" 
               newer="true"
               serverTimeZoneConfig="${ftp.server.timezone}"
               >
  
  
  

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


Mime
View raw message