SyncThing deleted my files - again

I’ve been using SyncThing for years, and this issue keeps popping up and it’s getting on y nerves past the last straw.

I had a folder of pictures I was syncing to/from my PC and my phone. I created a folder on my PC with these pictures, added the folder to SyncThing on my PC, and set it to share to my phone. I also set it to “send/receive” mode in case I add or delete photos to that folder on my phone.

Here’s the part that ruined everything for me: I didn’t do any changes to folder anywhere, not on my PC nor on my phone. I go to bed, and wake up to find the entire contents of this folder completely clean. You know why?

SyncThing decided that my phone was the source of the folder - since it didn’t have anything in the folder on my phone, SyncThing decided to delete all my photos on my PC’s folder.

yes, I should’ve put a file versioning scheme on this folder and had a backup. But the fact that within minutes SyncThing wiped my folder entirely is not just bizarre, but completely insane. Why would it default to using my phone’s version of the folder as the source of truth on the first sync?

From now on I guess I’ll have two copies of all my folders, one for SyncThing to possibly destroy and another for backup, plus have file versioning on all the time from the start.

1 Like

Syncthing doesn’t behave like you described. Clearly something happened - maybe the photos were synced to the phone, then something deleted or moved them there and that got synced back - but sharing files with an empty other side does not result in a delete on the source.

That doesn’t help narrow down what happened in your case unless you can reproduce it, but I feel I need to note it for the protocol regardless.

Generally speaking there’s a lot of magic going on on phones, especially around photo albums managed by the phone in question. Bidirectionally syncing that with somewhere else (or another phone) seems error prone.

When I added the folder on my phone, I got a notification from Google Photos asking to backup that folder, and I said no. When I’ve done this with other folders that weren’t also in SyncThing, the files remained, so I doubt it’s related to any other backup service.

I specifically use SyncTrazor, which kept the logs of what happened with the files, and lo and behold, the files I mentioned were definitely deleted by SyncThing / SyncTrazor. It even tried to delete two sub-directories, but failed with “directory has been deleted on a remote device but is not empty the contents are probably ignored on that remote device but not locally”.

So somehow, after scanning all the files in this folder that I added to SyncThing on my PC, then adding that folder to my phone, SyncThing decided to delete all the files because they didn’t exist on my phone.

I’m not saying Syncthing didn’t delete your photos, but,

that is not the decision process and not the reason.

A file is deleted by Syncthing for one reason: another device sends an update that says “I had this file, but it is now gone, deleted by the user”. We can inspect the database records (the /rest/db/file endpoint) and my guess is they’ll say the file was present and then deleted on the phone. How did that happen? I have no idea. Maybe the files were synced to there and then deleted by some other program. Maybe the files appeared to sync from Syncthing’s point of view but then disappeared due to a filesystem becoming unmounted/encrypted/unavailable/broken. Maybe something else happened with the storage. Maybe there’s a Syncthing bug that interacts with something on the phone.

It is not the case that we simply delete files because they are not present on the other side. If that were the case it would be impossible to ever share a non-empty folder with another device.

Is there any safety switch to prevent the situation like unmounted/unavailable directory causing this behavior? Maybe if the entire repo disappears Syncthing shouldn’t instantly propagate the change but ask the user first? Or make it a per repo option. Some directories for temprorary file exchange may become empty often just because the files come and go. And some with important data should be protected from this.

Besides, there’s always a directory named .stfolder (probably not on Android though), I suppose if it disappears Syncthing considers this an error and doesn’t wipe out the contents on the other side? Anyway, an option to protect against such accidental wipes would be very nice to have.

That directory exists everywhere and acts exactly as the safety switch you describe. That protection is always enabled (and will ever be so).

1 Like