In this article we'll explain how Resilio Connect Agents work to process the renames of directories and files. For simplicity we'll refer to all renamed items as 'file'.
For any operating system a rename is equivalent to deleting old_filename and creating new_filename. The hash of the file remains the same. When one Agent notices a renamed file, other Agents process it through the Archive: old_filename is moved to the Archive, however instead of re-downloading the new_filename, they take it out from the Archive.
There are several scenarios possible but here is the ideal scenario:
1. File example.txt is renamed to example2.txt on agent A.
2. Remote agents detect that example.txt file is missing on peer A and moves the file into the Archive.
3. After some time, remote agents detect that example2.txt file appeared. They check if there is a file with the same hash in the Archive folder. If there is such a file, agents move it back with a new name.
This flow allows to avoid unnecessary re-transmitting of the data and save bandwidth. Thus, you need to have Archive option enabled, otherwise files will be re-synced again.
Here's this example, illustrated. At first, there are two identical files on both agents. Each file has a hash value, Agent calculates it and stores in the database.
Then file is renamed on agent A:
Agent B detects that there is no example.txt file and moves its copy of the file to the Archive folder:
After some time, Agent B detects that there is a new file on Agent A. First, it checks if Archive has the file with the same hash and determines that there is such a file:
Then Agent moves the file from the archive to the previous location with the new name:
And now both agent have the same file again: