Davejkane / riv

Riv - The Rust Image Viewer
MIT License
99 stars 10 forks source link

d for move to trash (OS specific). D for force delete (current behaviour) #66

Closed sadid closed 5 years ago

sadid commented 5 years ago

While I love the vim style and the uninterrupted/fast deletion procedure of riv by 'd' (very convenient), however this behavior makes riv not safe for me. Because, just by even one accidental press of d, the image will be removed (by rm?) and this is a bit worrisome for me.

I think, if d (or D) remove the image in the same procedure but:

would be much better

Davejkane commented 5 years ago

@sadid Thanks for the input, so nice to get our first user feedback.

I had something similar in mind. Was also thinking d for a delete confirmation dialogue (in the information bar at the bottom), D for force delete. This has only very recently come into scope with the new interactive command bar functionality, so we'll look at this soon. For now, please be careful with your images, and I'm sorry if you lost anything important.

sadid commented 5 years ago

I just want to emphasis that I love the no-confirmation approach. Personally, I prefer the folder approach (like 'keep' a 'delete' folder for example), since I usually call riv from my ranger rifle and working with directory is easy. This way it integrate better with my vim/ranger/riv workflow.

Moreover, I want to thank you for your software. It's inspiring and I like to use it more. Also no loss, I was just testing it.

Davejkane commented 5 years ago

@sadid, I think if I was going with a folder approach, I would use the ~/.Trash on mac, $recycle_bin on windows, and then whatever we have on linux (probably 101 different possibilities).

gurgalex commented 5 years ago

@Davejkane Not sure what to do for Windows trash support without adding winapi-rs as a crate dependency. as it is not a path, but a "VIRTUAL" folder.

deleting a file for Windows 8+ Though, we need to somehow set the OperationFlags to only trash the file

There doesn't appear to be a cross platform "move to trash" feature provided by a crate that I could find. dirs or directory-rs https://github.com/soc/directories-rs/issues/18

Davejkane commented 5 years ago

@gurgalex, that's a little disappointing, but thanks for looking into it. Will be an interesting challenge.

Davejkane commented 5 years ago

After reading into this https://github.com/nivekuil/rip, I think our solution should be threefold.

gurgalex commented 5 years ago

Doesn't seem quite as simple for Linux as I thought.

Need to correctly handle trashing a file. https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html

As someone may want to restore it.

MacOS requires finding the right bindings for trash operations. I don't have a Mac, so we'll see how much work can be done with no testing.

Windows is slightly easier as I have the machine to test on.

Davejkane commented 5 years ago

@gurgalex do you want to take this one? If all of this is too much hassle we could just follow the same as above, but with just a regular directory as the os specific path.

So cascading importance would be cli arg > env var > default path (os specific).

Davejkane commented 5 years ago

If you don't want it, I don't mind taking it.

gurgalex commented 5 years ago

@Davejkane I'll work on this (or parts of it) depending on what we go with.

If we go with having our own default directory, we'll need a way for the program to restore the files to the location they were moved from. Which I'll probably go with the freedesktop.org trash spec, as they say it can work across platforms.

If we go with native trash support, I can do linux and Windows. I'll need you to implement the trash support for Mac OS.

https://developer.apple.com/documentation/foundation/nsfilemanager/1414306-trashitematurl?language=objc

gurgalex commented 5 years ago

@Davejkane I've got an initial draft for OS specific trash support (linux only so far)

This can be pushed to when implementing Mac OS trash support.

gurgalex commented 5 years ago

Closed by #93