syncthing icon indicating copy to clipboard operation
syncthing copied to clipboard

Inherit compression attribute from previous file version

Open sagamusix opened this issue 3 years ago • 3 comments

On Windows, it is possible to enable NTFS compression per file or per folder, and in the latter case it is also possible to exclude specific files inside a folder from being compressed.

When Syncthing downloads a new version of a file that sits inside a folder with NTFS compression enabled, but the file itself doesn't have the compression attribute set, the new version of the file inherits the compression attribute from the folder nevertheless.

It would be great if Syncthing could honor the previous compression flag of the file and keep compression disabled. I didn't test if the other way around works already, but similarly I would expect that a compressed file stays compressed when a new version is downloaded.

Use case: Some tools such as a VeraCrypt are not compatible with NTFS compression.

sagamusix avatar Jun 29 '22 17:06 sagamusix

The behaviour described here is essentially how NTFS compression works, isn't it? If you perform the same process manually, without Syncthing involved, i.e. create a new folder, enable compression for it, put an uncompressed file there, and then overwrite the file with a new one, also uncompressed. The final file will end up being compressed.

tomasz1986 avatar Jun 29 '22 18:06 tomasz1986

No, the file will stay uncompressed - I verified that with both Explorer and via the command line. I suppose the problem here is that Syncthing technically moves the existing file to .stversions and creates a new file with the updated contents, which then of course cannot inherit the attributes from the old file?

sagamusix avatar Jun 29 '22 18:06 sagamusix

Yeah, if that's the case, this means that the problem is about Syncthing removing the original file first, and only then renaming the temp file to take its place. The temp file itself is probably created compressed from the very beginning.

The same applies to other attributes, such as hidden, etc. Not sure about encrypted.

tomasz1986 avatar Jun 29 '22 18:06 tomasz1986