Feature Request: Include Unique Token in .stfolder Marker

Hello:

Ok - definitely a niche feature request here: :wink:

I have two laptops I use as mirrored systems, both with external drives. These drives are named the same as their counterparts on the other system, to maintain easy transfer of projects between the two systems.

It hasn’t yet been an issue - but I can foresee the day when I accidentally plug a drive into the wrong system, and Syncthing gets to work on it. If the sync is 100% complete before I do this, I guess no harm will result; but if the sync wasn’t 100% complete, then I presume Bad Things Are Going To Happen.

Can I propose that a unique token is stored inside the .stfolder marker - perhaps a concatenation of the Device ID and Folder ID - so that when Syncthing encounters an expected folder path, it first checks the token is also expected before launching into its sync process for the folder?

Niche, I know - but just trying to avoid shooting myself in the foot in the future… :laughing:

If you want to spend your own time implementing this, sure, PRs welcome, but .stfolder used to be a file so there also needs to be a migration path etc.

I don’t think anyone cares enough about a problem specific to you to address this universally.

You could work around this by putting all the content in a subfolder, this way differentiating between the drives.

Currently .stfolder is created as an empty folder. I see no harm in creating an .stfolder/id with something magic in.

If developing code for the main syncthing is not an option, you could probably make your own script that helps with this. Take Jakob’s suggestion of an ID file inside the .stfolder/ and then write your own script that handles pausing/starting/stopping of syncthing. When a new USB device is detected pause syncthing. only restart it if the ID file matches. If it doesn’t, then stop it. Only start Syncthing at boot if the ID files match.

3 Likes