Browse Source

Add logging of local vs remote timestamps in <ftp> task.

PR:31812


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278381 13f79535-47bb-0310-9956-ffa450edef68
master
Steven M. Cohen 20 years ago
parent
commit
11f0a89542
1 changed files with 28 additions and 8 deletions
  1. +28
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 28
- 8
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -26,7 +26,9 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -1817,6 +1819,10 @@ public class FTP
} }
return null; return null;
} }
private static final SimpleDateFormat TIMESTAMP_LOGGING_SDF =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/** /**
* Checks to see if the remote file is current as compared with the local * Checks to see if the remote file is current as compared with the local
* file. Returns true if the target file is up to date. * file. Returns true if the target file is up to date.
@@ -1853,16 +1859,30 @@ public class FTP


long remoteTimestamp = files[0].getTimestamp().getTime().getTime(); long remoteTimestamp = files[0].getTimestamp().getTime().getTime();
long localTimestamp = localFile.lastModified(); long localTimestamp = localFile.lastModified();
long adjustedRemoteTimestamp =
remoteTimestamp + this.timeDiffMillis + this.granularityMillis;
StringBuffer msg = new StringBuffer(" [")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp)))
.append("] local");
log(msg.toString(), Project.MSG_VERBOSE);
msg = new StringBuffer(" [")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp)))
.append("] remote");
if (remoteTimestamp != adjustedRemoteTimestamp) {
msg.append(" - (raw: ")
.append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp)))
.append(")");
}
log(msg.toString(), Project.MSG_VERBOSE);

if (this.action == SEND_FILES) { if (this.action == SEND_FILES) {
return remoteTimestamp
+ this.timeDiffMillis
+ this.granularityMillis
>= localTimestamp;
return adjustedRemoteTimestamp >= localTimestamp;
} else { } else {
return localTimestamp
>= remoteTimestamp
+ this.timeDiffMillis
+ this.granularityMillis;
return localTimestamp >= adjustedRemoteTimestamp;
} }
} }




Loading…
Cancel
Save