Problems with versioning in nested folders

I have observed this behaviour in nested folders, which is that when versioning is enabled both in parent and child folders, files are versioned randomly between the two.

For instance, if the folder structure looks like

Dir1
  Dir2

and we delete files in Dir2, then versioning will move them randomly either to .stversions in Dir1 or .stversions in Dir2. Where specific files go seems to be totally random.

Is this correct? If yes, then I guess that there is no fix/workaround other than simply not enabling versioning in child folders, right?

Syncthing applies versioning when changes from remote devices are handled. If the change comes in on the dir1 folder that’s where it’ll get versioned, and vice versa. So this is totally dependent on where the change originated.

In this case, I have the same two folders on both Device A and B. The same change occurs simultaneously in both folders on A, and then is pushed to B. I guess that this means that the first to come to B wins, right? The other folder cannot version the file, because it does not exist anymore.

Correct. “Simultaneously” or not, one will in practice happen before the other.

(Why are you doing this? Don’t do this. Nested folders have their place, but why do the nesting on both sides…?)

The reason is because the config looks like this.

Device A
  Folder 1
    Folder 2
Device B
  Folder 1
    Folder 2
Device C
  Folder 2

Everything is interconnected and set to “Introducer”, so the nested folders get automatically shared between all devices, even though they should not be when their parent folder is present on both devices, but I do not want to give up using “Introducer”, so I just let them be.

Is there any better way to configure this, other than not using “Introducer” and sharing everything manually?

But why folder 2 on device B? Folder 1 covers it, no?

It does, but I still want to have the folder synced between Device B and Device C when Device A has gone kaput.

It goes like this.

  1. I share Folder 1 between Device A and Device B.
  2. I share Folder 2 between Device A and Device C, and between Device B and Device C.
  3. Because of “Introducer”, Folder 2 gets automatically shared between Device A and Device B.

Then either live with the uncertainty or put the folder non-nested on B I think.

Yeah, I will probably leave things as they are. I have been experimenting with very lightweight versioning of 1-day trashcan anyway, just for emergencies, so as long as the files do get versioned somewhere, I am fine with it. I have proper backups with snapshots otherwise if I need to do actual serious restoration.

As for changing the folder structure on B, I would like to avoid doing so, as I strongly prefer to keep the structure the same if possible, just for consistency. Also, I have been trying to reduce the number of top folders, not to increase it, so there is that too.

Edit:

I just want to add one last warning in case someone else experiences this problem with nested folders automatically shared due to using introducer.

Basically, Syncthing will happily sync everything inside the nested folder. This includes both the nested folder itself and also all its internal files and folders like .stfolder, .stignore, and .stversions. Therefore, I would say that it is an absolute must to add those to the ignore patterns of the parent folder, unless you do want to get them actually synced.

However, syncing the child folder’s .stversions leads to an infinite delete loop, where both sides keep versioning files deleted from .stversions creating a massive folder tree inside it.

I do not know why I have not though about this before, but the obvious solution to the problem is to use external versioning, possibly even setting it to just move the files versioned in the child folder to the parent’s .stversions. This way the problem of the versioned files being spread across different .stversions is solved.