Skip to content
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

Use LastWriteTimeUtc when files have the exact same length #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manu-st
Copy link

@manu-st manu-st commented Jun 30, 2016

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.

This is to address issue #33

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.
@x2764tech
Copy link

x2764tech commented Aug 3, 2016

@manu-silicon FileInfo.LastWriteTimeUtc doesn't seem to be supported on Windows Phone or Silverlight

@manu-st
Copy link
Author

manu-st commented Aug 4, 2016

There is LastWriteTime which would work for those platforms. Since this is just trying to copy files that have been changed while keeping the same size, it might still work better than not copying them at all. In any case the proposed PR is not a full solution. I would actually rather always copy the files rather than trying to be smart as this is very hard to fix from the client side.

@x2764tech
Copy link

Maybe a better way would be allow passing a Func<SftpFile, FileInfo, bool> (or create a delegate with a similar signature) to let you override comparison? This way, people can implement their own strategies

@jenshenneberg
Copy link

Some sftp servers, for instance DoveTail Co:Z SFTP (On z/OS mainframe), does not support MD5, gives only an approximate file length and gives a timestamp that is NOT equal to LastWriteTime(It is the last access time instead). The reasons for this are, as far as I know, technical limitations on z/OS.

So in that scenario the only sensible file comparison during synchronization is on filename, unfortunately.

For that reason I would suggest either the delegate of func as x2764tech suggested, or a SyncOption class/enum to specify behavior.

@x2764tech
Copy link

@jenshenneberg maybe we could build in some default delegates:

public static class SyncOptions
{
    public static bool Default(SftpFile remoteFile, FileInfo localFile) 
    {  
        return localFile.Length != temp.Length;
    }
}

These could then be used like an enum:

client.SynchronizeDirectories("/", @"C:\temp\", "*.*", SyncOptions.Default);

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

Successfully merging this pull request may close these issues.

3 participants