Symlinks implementation

I always found that how Syncthing handles symlinks to be a little surprising. For example when syncthing between Linux and Android, the sync simply fails.

As specimen on why this is important: the software I code frequently uses symlinks on “/usr/bin”, and it’s backed up on my phone. I had to resort to substitute those links for plain scripts, and my programs now have to run an extra process due to that.

I have been reading your post about how implementing symlinks is problematic among platforms.

Maybe the answer is simpler, doing something worse but effective. That is not syncing symlinks on platforms that don’t support it. But instead substituting the symlink for a plain text file, with a specific extension, with the link reference in it.

file →

[path to target]

Hence when that file is synced into a platform that supports symlinks it is converted into a symlink, but if the platform doesn’t support them it’s simply the plain text file.

That way you give up those links to be functional, but you can retain the capability of syncing them consistently and in a simple manner among platforms.


On the other hand we’d give up the ability to sync a normal text file that begins with #symlink. And if we claimed to be “in sync” someone might validly question that, if we just replaced symlinks with text files and called it a day – your application wouldn’t work, for example.

Annoying as it may be for your use case, I think the current setup is at least clear about what’s going on. You can’t have symlinks on FAT (or maybe on Android at all, I forget), so you don’t get any…

Most likely if a symlink doesn’t work in a platform that doesn’t support it, it’s mostly warranted that the software using the link also doesn’t run. So probably it doesn’t matter.

Also that clarity you are talking about seems rather clarity on the technology, but not on the behavior.

The least surprising thing for me would be files to always sync.

To pretend to “always be in sync” by the virtue of lying is not great in my opinion.

Yes, being always in “sync” (by your definition) is least surprising. But it’s super surprising to find your files replaced with text files.

I think it’s best to be honest about what we can and cannot do, and for things we cannot do, get the user to address it.

1 Like