Is there any sync algorithm / link to sync a directory?
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 to share