How does unison decide which way to sync a file
Asked Answered
A

1

6

I am using unison to sync a bunch of folders together. Not just 2 roots, but I think my question can be made this simple...

Lets say I am syncing directory A and B using unison. If I remove file X from directory A, how does unison know what to do? Should it add X back to A from B or should it delete X from B?

Agglomerate answered 21/12, 2010 at 22:0 Comment(0)
C
9

Unison keeps a record of the contents of each path after each successful synchronization of that path (i.e., it remembers the contents at the last moment when they were the same in the two replicas).

We say that a path is updated (in some replica) if its current contents are different from its contents the last time it was successfully synchronized. Note that whether a path is updated has nothing to do with its last modification time—Unison considers only the contents when determining whether an update has occurred. This means that touching a file without changing its contents will not be recognized as an update. A file can even be changed several times and then changed back to its original contents; as long as Unison is only run at the end of this process, no update will be recognized.

In other words: Unison knows that you have deleted file X, because it's no longer on the disk in A, it knows it should delete it from B.

Cyaneous answered 22/12, 2010 at 7:13 Comment(3)
What about a 'fresh start' synchronization? If I have files in A, and nothing in B, and start a sync from A - will files be copied to B, or removed from A?Saffren
In this case, it will merge the 2 roots, meaning, the files will be added on both ends, nothing will be deleted.Naldo
In a 'fresh start' synchronization, it will actually ask before adding the file on the other end. Unison does not know if A or B is "correct" in this case. So it will give you the option to either add it or remove it from both ends.Benelux

© 2022 - 2024 — McMap. All rights reserved.