Conflict resolution - SilverEzhik/fmtest GitHub Wiki

Ideally, conflict resolution is handled on FM level - checking for the necessary permissions beforehand, asking about overwriting/renaming files and merging folders. This also can make easier things like the FS layer doing these operations in a separate process.

One issue with this idea is that something being guaranteed at the time when the permission check was performed does not guarantee that this permission will be there at the time the file is actually written. These are edge cases, but they need to be handled gracefully. Example:

  1. Start copy operation for File 1 and File 2, confirm permissions first
  2. While File 1 is being written, the destination for File 2 gets taken up
  3. There is now a conflict - should the new file be overwritten? Can it be overwritten?

Originally, the plan was to overwrite, but would that really be what the user would want? Who is supposed to win in this scenario: cp file1 destination -f & cp file2 destination -f?

One solution to this is to stub out all of the files that are to be copied, but this can create an incredible mess (imagine 10000 empty stub files in a directory if your computer crashed mid-copy).

So, for now the answer is to do both.

  1. Stake out the copy, ask for permissions to overwrite there and then
  2. Notify if conflicts occur during copy as well and ask for permissions
  3. Notify if fatal permission errors happen (but try to continue where possible)

There are other things to consider here, however - for example, speed. How well would this fare on slow external HDDs, for examples?