Skip to content

Sftp SynchronizeDirectories should not just use the size of the file to sync/update #33

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
manu-st opened this issue Jun 28, 2016 · 2 comments

Comments

@manu-st
Copy link

manu-st commented Jun 28, 2016

Currently the implementation of SynchronizeDirectories from SftpClient uses the size of the file to know if it needs to override it. Unfortunately this is not good enough in most cases. There is a comment about using MD5, which would be nice indeed. In the meantime, could we use a some file stamp comparison?

@manu-st manu-st changed the title Sftp SynchronizeDirectories should not just use the size of the file Sftp SynchronizeDirectories should not just use the size of the file to sync/update Jun 28, 2016
@manu-st
Copy link
Author

manu-st commented Jun 30, 2016

I'm proposing changing this line of code:
isDifferent = localFile.Length != dest.Length;
to read
isDifferent = (localFile.Length != dest.Length) || (dest.LastWriteTimeUtc.AddSeconds(-60.0) <= localFile.LastWriteTimeUtc);

The 60s is to avoid any potential clock differences between machines.

@raffaeler
Copy link

I would keep the difference in no more than 10 seconds. If you are actively working on some files, 1 minute is definitely too much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants