Reputation: 1949
I'm planning to write a program to sync a folder in real time across multiple computers over the internet. I'm wondering if there is any sync algorithm to handle file sync conflicts, ie, computer A tries to save a file, while computer B has removed the file.
Upvotes: 2
Views: 6225
Reputation: 4772
You might also want to look into Unison. It is a multidirectional file synchronization tool that uses the rsync algorithm to make sure that only the changed parts of files are sent.
Upvotes: 3
Reputation: 33667
The example you gave is exactly why synchronization is considered a hard problem.
Computer A has deleted a file which computer B still has. Now: how do you know if the file was added on B, and should be copied to A, or deleted on A, and should be deleted on B? You don't, really. Many synchronization systems have the possibility of conflicting changes which need to be resolved by a human.
Many tools have already been built to do synchronization, including:
Upvotes: 8