Small bash script to resolve conflicts

Hello,

I use Syncthing to sync my configuration files for, e.g., Emacs, Vimperator, etc. When I have more computers running, sync conflicts arise naturally and have to be resolved. Mostly, those conflicts are about changes in configuration files, or bookmarks and so on.

I wanted to announce a small bash script that I wrote to handle sync conflicts in text files similar to the pacdiff utility from Arch Linux. A diff utility can be used to merge the files and keep them up to date.

The source code is available at https://github.com/dschrempf/syncthing-resolve-conflicts.

I appreciate your feedback.

Thanks, Dominik

5 Likes

Sweet! Add it to the community contributions page in the docs, as well.

1 Like

I like it! Is there a way to make it check for conflicts? I stole parts of your code and made it a startup script and think about making it a cronjob.

Thanks for your interest!

This script is not checking for conflicts itself, it uses locate to do so. You can also use find when issuing the -f flag. However, this takes much longer, because there is no pre-populated database to be queried. Of course, we could implement other search engines. Let me know what you think.

Does this answer your question?

EDIT: The conflict resolution is still interactive (and should be interactive) so it is not suitable for a cron job. Finding conflicts, of course, is very much suitable for a cron job. (But doesn’t Syncthing report conflicts anyway, so maybe scraping the log would be better?)

Hello Dominik, You’re right. But since I would run it not too frequently I wouldn’t be bothered by the couple of seconds it takes, especially since it’s in the background. I just made myself a quick and dirty way. I don’t know too much about syncthing, scripting and the like but it sure seems like there are smarter ways to do this, e.g. sifting through the log. I just don’t know how to do it yet. Because I am not fully able to grasp your script I asked whether it had that functionality. For now I am totally fine with my version though but sure would be happy about pointers on how to read the log. Ideally it would result in a notify-send bringing the conflict to my attention.