Mapping of File Events to Actions

File System Events

The File Agent raises the following events in response to local changes:

  • Creation
  • Modification
  • Deletion
  • Move (also raised for renames)

Actions

The actions that can be performed in response to local events are:

  • Upload the file
  • Delete the file from the server
  • Flag the file in Conflict

Mappings

Local file events map to actions as follows:

File Event Local File Exists Server File Exists C==S Network Action Local Action
Create/Change Yes No NA Upload Mark Normal
Yes Yes Skip Mark Normal
No Upload Mark Normal
No _ _ Skip Delete Entry
Delete _ Yes _ Trash Delete Entry
No _ Skip1 Delete Entry
Move _ _ _ Rename Mark Normal, Rename Entry

[1] The client always tries to move the server file to the Trash. If the file does not exist, the client ignores the 404 error, effectively skipping the file.

Legend
C==S : Local actual file hash matches the current server hash
NA : Info not available
_ : Do not check

Proposed Mappings

The following mappings will be used to handle missed conflicts

File Event Local File Exists Server File Exists C==S Cs==S Network Action Local Action Comments
Create Yes No NA _ Upload Mark Normal
Yes Yes _ Skip Mark Normal
No _ Upload Mark Normal
No _ _ _ Skip Delete Entry
Change Yes No NA _ Upload Mark Normal
Yes Yes _ Skip Mark Normal
No _ Upload Mark Normal
No _ _ _ Skip Delete Entry
Delete _ Yes _ Yes Trash Delete Entry
_ No Skip Mark Conflict
No _ _ Skip Delete Entry
Move _2 From:Yes To:No Yes _ Rename Mark Normal, Rename Entry
No _ Skip Mark Conflict, Rename Entry The file has changed since the last poll. The next poll will cause the file to download
From:No _ _ Skip Mark Conflict, Rename Entry We are trying to move a missing server file. We could upload it but the user should be warned
From:Yes To:Yes From:Yes To:Yes From:Yes && To:Yes3 _ Rename Mark Normal, Rename Entry The user is overwriting the target file
From:No or To:No _ Skip Mark Conflict, Rename Entry The file has changed since the last poll. The next poll will cause the file to download
From:Yes To:No From:Yes To:Yes _ _ Skip Mark Conflict, Rename Entry The user is NOT overwriting the target file

[2]: Move actions for non-existent files are blocked by the WorkflowAgent
[3]: In order to allow the overwrite, the hashes of the client source and target files must match the server's source and target files. Otherwise one of the two server files has changed and we must abort the overwrite.

Legend
Cs The local file hash that is stored in the local state database
Cs==S: The current server hash (S) matches the last stored hash in the file state database. This is the only possible source for the local hash since the local file no longer exists

Double renames

Assume the client and the server both have a file called bar. The file is renamed at the client to bar1 and at the server to bar2.

The following steps assume that the proposed mappings have been implemented. In both cases we end up with

If the client tries the rename first

  • When the client tries to move the server file it will detect that there is no source file.
  • Mark a conflict for bar1 and rename the state entry to bar1.
  • At the next poll, the client sees the rename from bar to bar2 and tries to rename the local file. Since the file is missing, we have a conflict.
  • Mark a conflict for bar2.

If the client tries the poll first

  • When the client tries to move the local file it will detect that there is no source file.
  • Mark a conflict for bar2
  • When the client tries to send the move to the server, it will detect that there is no server source file
  • Mark a conflict for bar1 and rename the original entry

Object IDs

Conflict resolution will be easier if we can use the file's Object ID to detect whether an existing source or target file corresponds to a local file, and detect the actual file names in case of a double rename.