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.
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.
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.
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.