Instead of Syncthing using an .stfolder
marker to identify a folder under it’s care, what if it recorded the DeviceId/FileId of the folder’s root directory in the folder’s config? This information is available in all environments that Syncthing compiles for. See https://github.com/rasa/godupless/blob/b8ec113b2ecd4d1c72d99384389ed5b3a0f86e91/file/file.go#L58 . This would actually be much safer than using a generic .stfolder
marker across all folders.
For example, let’s say a user has two USB disks mounted at D:
and E:
. The user shares two folders, the first as D:\
and the second as E:\
. Both now have an .stfolder
marker. If the user (or Windows!) decides to swap the drive letters, both folders would have all their files removed without warning. Or if a new drive D:
was added, and the old D:\
now is mounted as E:\
, all of the second folder’s files would be deleted.
The same thing could happen on Linux, if a user unknowingly swapped /mnt/d
and /mnt/e
.
I could whip up a PR to store the DeviceId/FileIds pretty quickly. The tricky part would be how to handle when Syncthing detects the IDs changing.
When that happens Syncthing should probably set the folder as “read only”, then scan the folder and compare it to what’s in its database, and if the two are different, ask the user how to proceed. Right?