Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files removes a Git directory without asking for confirmation #363

Open
jelly opened this issue Apr 10, 2024 · 2 comments
Open

Files removes a Git directory without asking for confirmation #363

jelly opened this issue Apr 10, 2024 · 2 comments
Labels
bug Something isn't working needs-design

Comments

@jelly
Copy link
Member

jelly commented Apr 10, 2024

Files behaviour on removing directories is different from the CLI experience:

For example trying to delete a git checkout warns about write protected files:

[admin@fedora-39-127-0-0-2-2201 ~]$ /usr/bin/rm -r contrib5/
/usr/bin/rm: remove write-protected regular file 'contrib5/.git/objects/pack/pack-686af63e7ca53cd610a54f638f3cd1c193b25d1d.pack'?

In files the directory is removed without any warning.

Normally one would have to pass -f to remove such directory see the man page:

   Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force option is not  given,
   or  the  -i  or --interactive=always option is given, rm prompts the user for whether to remove the file.  If
   the response is not affirmative, the file is skipped.

What should Files do here, replicate rm's command line behaviour or not?

@jelly jelly added bug Something isn't working needs-design labels Apr 10, 2024
@martinpitt
Copy link
Member

IMHO we should model this after graphical file browsers like nautilus or pcmanfm. The CLI has different "oopsie" vectors, such as rm myfile. * (note the very significant space!)

cp -a ~/upstream/starter-kit/ /tmp/

Trying to remove /tmp/starter-kit in pcmanfm doesn't ask me for any special confirmation. If I select a directory and say "delete", it does that. Of course GNOME etc. default to moving it to the trash. Maybe that's not a bad idea in cockpit-files either? And adding an equivalent to shift-delete?

@allisonkarlitskaya
Copy link
Member

2¢: I don't think we need to ask for special permission to delete git checkouts. The fact that rm does this is simply a side-effect of the fact that git marks its object files readonly. I've always considered it to be a weird filesystem limitation that there wasn't a better way to mark an inode immutable but otherwise completely normal from a permissions standpoint. I consider the fact that rm -r happens to prompt on git checkout to be a weird side-effect... and indeed, if you do rm -r on a git repository, chances are it's going to delete a bunch of files before it gets to the object db where it will prompt you...

As for the trash: implementing the XDG trash spec might be interesting, but probably a lot of work... I did the gvfs/gio work for that back in the day and it's pretty non-trivial....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-design
Projects
None yet
Development

No branches or pull requests

3 participants