how does syncthing decide which folder to prioritize? some hypothetical edge cases

Let’s start at the beginning.

You define a folder on device.1 that is full. The folder gets added to device.2 and pointed to an empty directory on device.2.

How does syncthing know it should copy the contents of the full directory on device.1 to the empty directory on device.2, and not sync the opposite way and empty the full directory on device.1?

Does syncthing just always assume the empty directory is the one to be copied to, specifically on an initial setup?


What if we change the hypothetical just a bit. What if the initial setup is a full folder on device.1 and the corresponding folder on device.2 just has two tiny files?

Is this just bad form? Should I just always make sure that both sides are either identical to start OR that one side is completely empty to start?


In reading the FAQ, it seems that syncthing does not have any concept of “Master” and “Slave” (or “Primary” and “Secondary”, or “Source” and “Destination”). It seems instead that having two different folders can result in a “race condition” to see which gets scanned first.

But that can’t always be true, can it? Or else a lot of people would be very angry when their full folders got wiped out in the initial setup, as I described in my questions above.


Here’s another hypothetical:

Let’s say device.1 has three files, file.1, file.2, and file.3, each 200 MB.

Let’s say device.2 is empty but only has a 500 MB capacity.

So device.1 starts syncing to device.2 (presumably, via whatever magic answers my question above) and successfully syncs file.1 and 'file.2`.

But then - oh no! - there’s no space to sync file.3.

Now, I’d assume at this point that syncthing would stop syncing until enough space is freed. But now file.3 is missing from device.2. Is there a risk at some point that syncthing will scan device.2, not find file.3, and then delete it from device.1?

Or does file.3 get flagged in the database as “to be synced” on device.1, and it won’t be touched, no matter the state of device.2 until that sync pushes through first?

I can’t edit posts here?

Anyway, continuing with this train of thought: I’m trying wrap my head around how Syncthing determines “priority” with two-way (or even multi-way) synchronization.

I mean, take a simple case where device.1 and device.2 have 10 files.

If I delete two files from device.2, how does Syncthing know, or decide, that it should delete those two files from device.1? If it’s just a matter of which folder gets scanned first as the FAQ implies, then couldn’t it instead decide to add the files back from device.1 to device.2, thinking it’s device.2 that tis out of sync instead of device.1? Or maybe I misunderstand the FAQ.

Syncthing syncs changes, essentially. If a file is new on disk it’s scanned and announced - if the other side doesn’t have it yet it will be downloaded. For a file to be deleted it needs to first exist so that syncthing knows about it, and then exist no longer - the deletion is then announced to other devices. Your questions should be answerable by applying this principle.

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