Symlinking ST config files

Syncthing 0.12.21 Linux Mint 17.3

I am using Syncthing to sync various config files across machines. The files live in ~/Sync/dotfiles and are symlinked to their respective locations. This works wonderfully, ST may as well be made by a certain fruit company, as it ‘just works’. Mad props to the team.

Curiously, ST itself does not play nice with this setup. Upon startup, it removes the symlink and copies its config file there. Not the default config, but the one I linked previously. Hence, as long as I don’t make any changes, I’m fine, but the file is not synced any longer.

$ sudo stop syncthing
$ rm -rf ~/.config/syncthing/*
$ cd ~/Sync/dotfiles/.config/syncthing_iris
$ for file in $(ls) ; ln -s $(pwd)/$file ~/.config/syncthing/$file
$ ls -al ~/.config/syncthing
total 16
lrwxrwxrwx 1 kalle kalle 57 Mar 24 12:56 cert.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/cert.pem
lrwxrwxrwx 1 kalle kalle 59 Mar 24 12:56 config.xml -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/config.xml
lrwxrwxrwx 1 kalle kalle 63 Mar 24 12:56 csrftokens.txt -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/csrftokens.txt
lrwxrwxrwx 1 kalle kalle 63 Mar 24 12:56 https-cert.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/https-cert.pem
lrwxrwxrwx 1 kalle kalle 62 Mar 24 12:56 https-key.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/https-key.pem
lrwxrwxrwx 1 kalle kalle 56 Mar 24 12:56 key.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/key.pem

$ sudo start syncthing

$ ls -al ~/.config/syncthing
total 24
lrwxrwxrwx 1 kalle kalle   57 Mar 24 12:56 cert.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/cert.pem
-rw------- 1 kalle kalle 4965 Mar 24 13:02 config.xml
lrwxrwxrwx 1 kalle kalle   63 Mar 24 12:56 csrftokens.txt -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/csrftokens.txt
lrwxrwxrwx 1 kalle kalle   63 Mar 24 12:56 https-cert.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/https-cert.pem
lrwxrwxrwx 1 kalle kalle   62 Mar 24 12:56 https-key.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/https-key.pem
drwxr-xr-x 2 kalle kalle 4096 Mar 24 13:02 index-v0.11.0.db
lrwxrwxrwx 1 kalle kalle   56 Mar 24 12:56 key.pem -> /home/kalle/Sync/dotfiles/.config/syncthing_iris/key.pem

What’s happening here? Thanks in advance for any help on this!

1 Like

When you save configuration, it replaces the existing file with a new one. This is by design to have atomicity.

:heart:

Indeed. But, …

I don’t think we should do this. Saving the config through the GUI is going to screw up your setup, but managing it manually should be fine. We do have migration steps at some points (v0.11 → v0.12 etc) which do cause automatic resaves on startup though…

As a possible workaround, can you try running with -home ~/Sync/dotfiles/.config/syncthing_iris and symlinking the index directory to somewhere else instead? You will suffer from a similar thing here (when upgrading to v0.13 you’ll gain a index-v0.13.0.db directory in there that then needs moving…) but it could work in the meantime.

As a longer term fix, I could imagine us not doing the atomic-replace dance if the target is a symlink. There may be consequences to that so we should consider it carefully first though.

I tried the workaround you proposed, ST syncs the symlink but does not seem to follow it. This seems fine to me, as I want to sync the configuration files but not the ever-changing db. Updating this with every major version update is acceptable while you guys consider carefully :slight_smile:

Considering the discussion in another thread concerning iOS support and such: I’ve had worse tech support from companies that asked a lot of money for it. I’ve used worse products, too. Syncthing is not great considering that it’s free, it’s great. You guys make my everyday life better. Thank you.

3 Likes

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