andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.62k stars 177 forks source link

Have --trash-dir skip the volume check #300

Closed raffaem closed 11 months ago

raffaem commented 1 year ago

I have a @home BTRFS subvolume which mounts /home/MYUSER, and a @ subvolume which mounts /.

I keep my data on /mnt/dataint/data/SOMETHING.

I can't trash from /mnt/dataint/data/SOMETHING. The two subvolumes are really on the same physical drives, it's just the default filesystem structure that I got:

❯ trash -v MYFILE.backup 
trash: volume of file: /
trash: trying trash dir: /home/MYUSER/.local/share/Trash from volume: /home
trash: won't use trash dir ~/.local/share/Trash because its volume (/home) in a different volume than MYFILE.backup (/)
trash: found unusable .Trash dir (should be a dir): /.Trash
trash: trash directory is not secure: /.Trash/1000
trash: trying trash dir: /.Trash-1000 from volume: /
trash: failed to trash MYFILE.backup in /.Trash-1000, because: [Errno 13] Permission denied: '/.Trash-1000'
trash: cannot trash regular file 'MYFILE.backup'

I really want to use /home/MYUSER/.local/share/Trash as that would be compatible with my desktop environment.

But setting the --trash-dir swith apparently doesn't skip the volume check.

I therefore request that the --trash-dir switch skip the volume check.

memchr commented 1 year ago

trash: won't use trash dir ~/.local/share/Trash because its volume (/home) in a different volume than MYFILE.backup (/)

IIRC, rflink can be used to move files across sub-volume boundaries on the same btrfs filesystem with no additional writes other than metadata, as long as none of them are marked as NOCOW. That's what coreutils does.

andreafrancia commented 11 months ago

This will be solved by the --home-fallback option. Unfortunately is not yet production ready.

You can try to use it but it is may not work.

TRASH_ENABLE_HOME_FALLBACK=1 trash-put --home-fallback <file-to-trash>

You need a recent version of trash-cli for trying it. Be sure to use the last version o at least >= 0.23.9.23 If this does not solve your problem comment again this issue indicating which version you used.