For file synchronization between Windows and Linux, even if the files have exactly the same content, the file contents will also be sent.

I use Syncthing to synchronize the git repository code between Windows and Linux. The folder on Windows is set to sendonly, and the folder on Linux is set to sendrecv. If the modification date of the file on Windows is older than that on Linux, but their contents are exactly the same, clicking the Override button on the Syncthing page will also fully transfer the content of the file instead of only updating the file metadata.

Syncthing on Windows

Syncthing on Linux

Click the button of Overide Changes

The file contents of the two directories are exactly the same git repository code. The total size of the directory is approximately 27M. The Windows directory filters out the.git directory, and the total size of the code is approximately 10M, but actually 10MB was transferred.

As I understand it, if the file contents are the same and only the modification time is different, the file content should not be transmitted. So is this a bug or a problem with my understanding?

Are you sure the contents are the same? By default git will check out with local line endings, for example, so the checked out files will differ even if they are “the same” in the git repo.

Thank you for the reply. The only difference of the file is that one is in Linux format and the other is in Windows format. But When the files in windows folder are newer, Syncthing will not transfer the file content but only update the file metadata on Linux. If the file format affects the calculation of the hash value, why do the performances of these two situations differ?

Maybe one side retains the format and the other enforces it, we can’t know. But yes, line endings are part of the data and hence the content is different.

The behavior shouldn’t be different.

As mentioned since the line endings are different the files are completely different.

I’m a little confused when you say it works one way but not the other because one of the folders is send only. So this is only ever a one way sync.

You are right. I made a mistake. After synchronizing the folders between Windows and Linux, I shut down Syncthing on Windows, deleted the git repository and re-cloned it. Since the file format of the git repo on Linux was already in DOS, the subsequent synchronization only updated the file metadata.

Will there be support for file hash calculation ignoring line breaks in the future? I’m not sure if such calculation can be achieved. Syncthing is an excellent cross-platform synchronization tool. If it could ignore file line breaks and synchronize files in formats that match the corresponding platforms, it would be even more useful. For example, when synchronizing shell scripts from Windows to Linux, due to the DOS format, they are actually not executable. It would be great if they could be automatically converted to the Linux format during synchronization.

Suspect that’s not gonna happen. If the files are small enough you may consider a script that mirrors your “source” scripts with one line ending standard into another local directory with the opposite line ending. Then synchronize both folders so you have both line endings on all sites and you can reference the appropriate directory on each machine based on the line endings needed for the platform.

It’s an ugly kludge but if you dont have a huge number of scripts it may make sense still.

1 Like

Thank you for the suggestions. I will consider it.

Line breaks are just bytes, yes you sync text files, hence they mostly don’t matter. The same characters appearing in an images would matter, because they are line breaks and represent something else, so what you are asking for is impossible.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.