Why syncthing need a ".stfolder" folder?

One thing bothers me: Why syncthing need a “.stfolder” folder in the synced folder?

Yesterday I used a clean app to clean my phone’s storage, one option is to delete empty folders and its checked by default. After this clean up, the Syncthing can’t work then, prompting “folder marker missing” error.

Then I manually created this “.stfolder” in every synced folder, Syncthing worked again.

So that raised this question to me: Why syncthing need a “.stfolder” folder even if the folder is just an empty folder and don’t store any valuable file? If it stores some information like modification timestamp, why it need to store in the “.stfolder” but not the Syncthing database?

No offense to this method, but apparently this “.stfolder” might make normal non-tech users confused and when non-tech people cleaned this folder unconsciously or accidently, it might be hard for them to fix this.


Update:

After some research, I just known that

If later the marker disappears we assume there was a mount issue and not sync that directory, as in case of a mount issue syncthing would see all files as removed, hence user intervention is required to resolve this issue.

I wonder if Syncthing could provide an advanced option, which don’t create “.stfolder”, and Syncthing could still work properly. As for mount issue, we can use another item option “Do not sync while the folder is empty.” to prevent removing all files caused by mount issue.

1 Like

The “do not sync” would have to mean, stop the folder. And this option would have to be enabled by default to prevent dataloss by default. So if you want to sync data from one device to the other, you would have to create a dummy file on that device just to start syncing the real files.

As the file .stfolder folder is hidden by default, no non-tech user would see it and thus wouldn’t be bothered by it.

The only exception is Android, for which there is (or will be) a workaround to create a file inside that folder.

The solution here is simple: Don’t activate an option on a random tool unless you actually need that option or you know exactly what it does and what might be possible ramifications. I doubt there’s a good reason to get rid of each and every empty directory (except OCD, but that’s definitely out of scope for Syncthing).

That workaround is in place since I think 1.5.0. It is in place because some vendors do the stupid thing of cleaning out empty dirs by default, i.e. it mitigates bad behaviour by vendors with less bad behaviour by Syncthing (creating an otherwise pointless file).

2 Likes

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