From f5261d6a4c5e5e12fb8b5bb13208d08ea5e8bdbf Mon Sep 17 00:00:00 2001 From: Manu Date: Thu, 30 Jun 2016 10:07:51 +0900 Subject: [PATCH] Use LastWriteTimeUtc when files have the exact same length This is to better see if files are different or not while waiting for the MD5 implementation. This is not bullet proof but better than what exists today. --- src/Renci.SshNet/SftpClient.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Renci.SshNet/SftpClient.cs b/src/Renci.SshNet/SftpClient.cs index 85a9d9fb1..ec30f8958 100644 --- a/src/Renci.SshNet/SftpClient.cs +++ b/src/Renci.SshNet/SftpClient.cs @@ -1681,10 +1681,11 @@ private IEnumerable InternalSynchronizeDirectories(string sourcePath, if (!isDifferent) { - var temp = destDict[localFile.Name]; + var dest = destDict[localFile.Name]; // TODO: Use md5 to detect a difference - //ltang: File exists at the destination => Using filesize to detect the difference - isDifferent = localFile.Length != temp.Length; + // ltang: File exists at the destination => Using filesize to detect the difference + // and the LastWriteTime (with a window of 60s to avoid clock differences between machines) + isDifferent = (localFile.Length != dest.Length) || (dest.LastWriteTimeUtc.AddSeconds(-60.0) <= localFile.LastWriteTimeUtc); } if (isDifferent)