Help Center

What if several users edit the file at the same time?

Connect Agents notice that a file’s updated if its size and/or timestamp have changed. Agents operate two timestamps:
- time_modified, mtime, this is something you can see in file's properties.
- inner file's timestamp, it's saved in share's database and is not visible to a user. This is the time when changes to this entry in database have been made - when agent detects the file change. In most cases it matches the mtime, but in some rare cases id doesn't, for example, if a file is moved or copied, mtime does not change, but the database time does.

Basically the file with the latest database time is considered the newest and will be synced. In cases when you deliberately put an old file into a folder (for example, when restoring it from Archive), the database time is taken into account.

If a file is updated every now and then, the behavior is pretty clear - file's mtime updates, agent detects that, verifies that mtime is newer than that on other agents and uploads the file to others.

But the situation when several people work with the same file at the same time is more common, and here it all becomes a bit more complex.

If several people update the same file on different devices, Agents will still synchronize the file with the latest database timestamp. 
This shall be done only if the Agent is online. Otherwise it’ll be just not watching all the ongoing file changes and will just compare its local file mtime with others when it’s back online. The file with the latest mtime will be synced.

Another vital condition is the local copy of file be available for rechecking and synchronization. Before deciding to download a remote file, agent will compare that with its local copy. Agent will not be able to accept/decline the remote file and synchronization will stall until the file’s checked. Same way it won’t be able to decide whether or not it needs to upload its copy of file, until file’s available.
This usually happens with, e.g., MS Office files, they’re open with exclusive access.

And one more condition stems from here: when exactly the app, with which file is being edited/opened, updates the mtime, whether it’s every time you click “save” while editing, or only after you close the file.

All these conditions play their role for agent to detect and decide which file is the latest.

Let’s see how it all works on a few simple examples. We have three agents and they are working with MS Document files: when a file is opened it’s not available for synchronization.

Case 1:

Suppose 3 agents are online. Agent1 updates a file and closes it, this file is uploaded to others. Then agent2 makes some changes, and this file version is uploaded to others - agent1 and agent3. And finally agent3 edits file, this file is uploaded to agent2 and agent3.

In this case, Agents will be syncing all the changes based on the mtime of the file - the latest is synced.


Case 2:

All three agents open the file. Agent1 edits the file, saves but does not close it. File won’t be uploaded - it cannot be rechecked yet. Agent2 edits the file and closes it. Agent1 and Agent3 cannot download it, cause their copy is still open. Agent1 closes its file. File’s rechecked and its database time becomes newer than that on agent2. File from agent1 is uploaded to agent2 and agent3. Agent3 still cannot download the file as it keeps its file open. Agent3 closes the file, without editing. It’s mtime is not updated, file is not updated in database, so it downloads the newest file from agent1.
If agent3 in any other way updated the file’s mtime, its version would be uploaded to other agents, even though nothing was edited inside the file.
So, it’s not who was the last to actually change the file. It’s whose file got the latest database time.


Agent 3 is offline. Agent1 and agent2 open the file. Agent1 edits and closes the file. File’s timestamp becomes the latest, and agent2 downloads it. In a while, the team decide that a week’s old file stored on agent3 is actually the one they need, put it to the folder and start agent3. The file with latests mtime from agent2 will be downloaded and replace the old file.
Agent3 and others must be online to correctly process the old file in this case.

Was the article helpful? Yes / No, send feedback on article Thanks!

Please note that we won't mail you back. This is just purely feedback on the article above. If you need help from our Support Team, please use the "Contact Support" link at the top of the page.