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)