Skip to content

Use LastWriteTimeUtc when files have the exact same length #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Renci.SshNet/SftpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,10 +1681,11 @@ private IEnumerable<FileInfo> 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)
Expand Down