mnutt / davros

Personal file storage server
Apache License 2.0
297 stars 35 forks source link

Does not warn on rename #137

Open timmc opened 2 years ago

timmc commented 2 years ago

If I create a fresh Davros grain and rename shuttle.jpg to pluto.jpg, pluto.jpg is overwritten. This matches the behavior of Unix's mv command, but should probably issue a warning/confirmation dialog.

(This is with experimental version 0.31.1.)

mnutt commented 2 years ago

That's a good call-out, I'll add a warning if the rename will potentially overwrite an existing file.

ocdtrekkie commented 2 years ago

Not tested, but can I assume it may do the same if you move pluto.jpg into a folder where a pluto.jpg already exists?

timmc commented 2 years ago

Yes, same result.

timmc commented 2 years ago

I wonder if it would also be worth doing a second check during the actual file move/rename operation, like so:

  1. Grain loaded
  2. User attempts to rename aaa.jpg to xxx.jpg (where xxx.jpg does not exist)
  3. [At some point since UI load, an xxx.jpg is uploaded]
  4. Second check happens just before the mv operation
  5. "Error: xxx.jpg already exists"
mnutt commented 2 years ago

The WebDAV spec handles MOVE conflicts by passing a header Overwrite: T or Overwrite: F. I think perhaps the right thing to do is to attempt to do the MOVE with Overwrite: F and catch the error, prompting to overwrite or cancel.

This works fine on single-file moves or renames, but is going to be tricky on files where many files may end up with conflicts...