Is there any sync algorithm / link to sync a directory?

I am planning to write a program to synchronize a folder in real time across multiple computers over the Internet. I'm wondering if there is some kind of sync algorithm to handle file sync conflicts i.e. Computer A is trying to save the file, and Computer B deleted the file.

+2


source to share


2 answers


The example you gave is exactly why synchronization is considered a difficult problem.

Computer A deleted a file that computer B still has. Now: how do you know if a file has been added to B and should be copied to or deleted to A and should be deleted on B? You don't really do it. Many synchronization systems have the potential for conflicting changes that need to be resolved by humans.



Many tools are already built for synchronization, including:

  • version control systems like CVS, Subversion, Mercurial, git, Perforce, etc.
  • stand-alone one-way synchronization programs. They cannot handle changes from both sides, but they can make the target directory look like the source directory. It's better than a full copy because it's faster, but it's actually the same thing. Examples include rsync, ROBOCOPY, and XCOPY / MIR on Windows.
  • easy-to-use Internet sync tools that sync folders across multiple machines. Examples include Windows Live Folder and Dropbox. These applications often resolve conflicts by making additional copies of both versions in subdirectories so that you can sort them later. They do assume that there are very few conflicts.
  • built-in sync in sophisticated applications like email / contacts / calendar sync in Microsoft Exchange, Lotus Notes, etc.
+8


source


You can also take a look at Unison . It is a multi-directional file synchronization tool that uses the rsync algorithm to ensure that only changed parts of files are uploaded.



+3


source







All Articles