From 11f0a8954237d3208179ca4404f47ad882591f56 Mon Sep 17 00:00:00 2001 From: "Steven M. Cohen" Date: Mon, 30 May 2005 17:56:33 +0000 Subject: [PATCH] Add logging of local vs remote timestamps in task. PR:31812 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278381 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/taskdefs/optional/net/FTP.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 7fd30606c..50bff8d00 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -26,7 +26,9 @@ import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.text.SimpleDateFormat; import java.util.Collection; +import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; @@ -1817,6 +1819,10 @@ public class FTP } 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 * 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 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) { - return remoteTimestamp - + this.timeDiffMillis - + this.granularityMillis - >= localTimestamp; + return adjustedRemoteTimestamp >= localTimestamp; } else { - return localTimestamp - >= remoteTimestamp - + this.timeDiffMillis - + this.granularityMillis; + return localTimestamp >= adjustedRemoteTimestamp; } }