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

trash-put --home-fallback (was: trash-put cannot trash regular empty file) #247

Open
andreafrancia opened this issue Sep 12, 2022 · 24 comments

Comments

@andreafrancia
Copy link
Owner

Hey @andreafrancia , I am facing the similar issue.

When I use trash-put in my home directory, it works perfectly as you can see
image

However, we have another disk \data and trash-put command does not work there.
image

I have created a .Trash-$UID dir and provided the permissions as mentioned in the documentation
chmod a+rw .Trash-$UID` chmod +t .Trash-$UID

I am not sure what to do. Could you please help me out?

Thanks,
Naman

Originally posted by @bnaman50 in #9 (comment)

@andreafrancia
Copy link
Owner Author

andreafrancia commented Sep 12, 2022

Please try these commands and send me the output:

$ trash-put --version
$ trash-list --debug-volumes
$ trash-put --verbose aa.txt

@bnaman50
Copy link

Thanks for your response, @andreafrancia.

Here are the output of the commands you asked me to run -

  • $ trash-put --version
    trash-put 0.22.8.27

  • $ trash-list --debug-volumes

Filesystem     1024-blocks      Used  Available Capacity Mounted on
tmpfs             13175148      3056   13172092       1% /run
/dev/nvme0n1p2  1844296244  44539852 1705997572       3% /
tmpfs             65875732         0   65875732       0% /dev/shm
tmpfs                 5120         4       5116       1% /run/lock
/dev/sda1       3844549616 110015020 3539167380       4% /data
/dev/nvme0n1p1      523248      5364     517884       2% /boot/efi
tmpfs             13175144        88   13175056       1% /run/user/125
tmpfs             13175144        68   13175076       1% /run/user/1011
tmpfs             13175144        72   13175072       1% /run/user/1006
physical ->
[sdiskpart(device='/dev/loop0', mountpoint='/snap/bare/5', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop1', mountpoint='/snap/core20/1611', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop2', mountpoint='/snap/firefox/1810', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop3', mountpoint='/snap/gnome-3-38-2004/115', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop4', mountpoint='/snap/gtk-common-themes/1535', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop5', mountpoint='/snap/snapd/16292', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop6', mountpoint='/snap/snapd-desktop-integration/14', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/loop7', mountpoint='/snap/core20/1623', fstype='squashfs', opts='ro,nodev,relatime,errors=continue', maxfile=256, maxpath=4096),
 sdiskpart(device='/dev/nvme0n1p1', mountpoint='/boot/efi', fstype='vfat', opts='rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro', maxfile=1530, maxpath=4096),
 sdiskpart(device='/dev/nvme0n1p2', mountpoint='/', fstype='ext4', opts='rw,relatime,errors=remount-ro,stripe=32', maxfile=255, maxpath=4096),
 sdiskpart(device='/dev/sda1', mountpoint='/data', fstype='ext4', opts='rw,relatime', maxfile=255, maxpath=4096)]
virtual ->
[sdiskpart(device='', mountpoint='/run/credentials/systemd-sysusers.service', fstype='ramfs', opts='ro,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='binfmt_misc', mountpoint='/proc/sys/fs/binfmt_misc', fstype='binfmt_misc', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='bpf', mountpoint='/sys/fs/bpf', fstype='bpf', opts='rw,nosuid,nodev,noexec,relatime,mode=700', maxfile=255, maxpath=4096),
 sdiskpart(device='cgroup2', mountpoint='/sys/fs/cgroup', fstype='cgroup2', opts='rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot', maxfile=255, maxpath=4096),
 sdiskpart(device='configfs', mountpoint='/sys/kernel/config', fstype='configfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='debugfs', mountpoint='/sys/kernel/debug', fstype='debugfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='devpts', mountpoint='/dev/pts', fstype='devpts', opts='rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000', maxfile=255, maxpath=4096),
 sdiskpart(device='efivarfs', mountpoint='/sys/firmware/efi/efivars', fstype='efivarfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='fusectl', mountpoint='/sys/fs/fuse/connections', fstype='fusectl', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='gvfsd-fuse', mountpoint='/run/user/125/gvfs', fstype='fuse.gvfsd-fuse', opts='rw,nosuid,nodev,relatime,user_id=125,group_id=130', maxfile=None, maxpath=4096),
 sdiskpart(device='gvfsd-fuse', mountpoint='/run/user/1011/gvfs', fstype='fuse.gvfsd-fuse', opts='rw,nosuid,nodev,relatime,user_id=1011,group_id=1012', maxfile=None, maxpath=4096),
 sdiskpart(device='gvfsd-fuse', mountpoint='/run/user/1006/gvfs', fstype='fuse.gvfsd-fuse', opts='rw,nosuid,nodev,relatime,user_id=1006,group_id=1007', maxfile=1024, maxpath=4096),
 sdiskpart(device='hugetlbfs', mountpoint='/dev/hugepages', fstype='hugetlbfs', opts='rw,relatime,pagesize=2M', maxfile=255, maxpath=4096),
 sdiskpart(device='mqueue', mountpoint='/dev/mqueue', fstype='mqueue', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='nsfs', mountpoint='/run/snapd/ns/firefox.mnt', fstype='nsfs', opts='rw', maxfile=255, maxpath=4096),
 sdiskpart(device='nsfs', mountpoint='/run/snapd/ns/snapd-desktop-integration.mnt', fstype='nsfs', opts='rw', maxfile=255, maxpath=4096),
 sdiskpart(device='portal', mountpoint='/run/user/125/doc', fstype='fuse.portal', opts='rw,nosuid,nodev,relatime,user_id=125,group_id=130', maxfile=None, maxpath=4096),
 sdiskpart(device='portal', mountpoint='/run/user/1011/doc', fstype='fuse.portal', opts='rw,nosuid,nodev,relatime,user_id=1011,group_id=1012', maxfile=None, maxpath=4096),
 sdiskpart(device='portal', mountpoint='/run/user/1006/doc', fstype='fuse.portal', opts='rw,nosuid,nodev,relatime,user_id=1006,group_id=1007', maxfile=None, maxpath=4096),
 sdiskpart(device='proc', mountpoint='/proc', fstype='proc', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='pstore', mountpoint='/sys/fs/pstore', fstype='pstore', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='securityfs', mountpoint='/sys/kernel/security', fstype='securityfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='sysfs', mountpoint='/sys', fstype='sysfs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='systemd-1', mountpoint='/proc/sys/fs/binfmt_misc', fstype='autofs', opts='rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=39086', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,relatime,size=13175148k,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/dev/shm', fstype='tmpfs', opts='rw,nosuid,nodev,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/lock', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,relatime,size=5120k,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/user/125', fstype='tmpfs', opts='rw,nosuid,nodev,relatime,size=13175144k,nr_inodes=3293786,mode=700,uid=125,gid=130,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/snapd/ns', fstype='tmpfs', opts='rw,nosuid,nodev,noexec,relatime,size=13175148k,mode=755,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/user/1011', fstype='tmpfs', opts='rw,nosuid,nodev,relatime,size=13175144k,nr_inodes=3293786,mode=700,uid=1011,gid=1012,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tmpfs', mountpoint='/run/user/1006', fstype='tmpfs', opts='rw,nosuid,nodev,relatime,size=13175144k,nr_inodes=3293786,mode=700,uid=1006,gid=1007,inode64', maxfile=255, maxpath=4096),
 sdiskpart(device='tracefs', mountpoint='/sys/kernel/tracing', fstype='tracefs', opts='rw,nosuid,nodev,noexec,relatime', maxfile=255, maxpath=4096),
 sdiskpart(device='udev', mountpoint='/dev', fstype='devtmpfs', opts='rw,nosuid,relatime,size=65840420k,nr_inodes=16460105,mode=755,inode64', maxfile=255, maxpath=4096)]
  • $ trash-put --verbose aa.txt
trash-put: Volume of file: /data
trash-put: Trash-dir: /home/naman/.local/share/Trash from volume: /
trash-put: found unusable .Trash dir (should be a dir): /data/.Trash
trash-put: Trash-dir: /data/.Trash-1006 from volume: /data
trash-put: Failed to trash aa.txt in /data/.Trash-1006, because: [Errno 13] Permission denied: '/data/.Trash-1006'
trash-put: cannot trash regular empty file 'aa.txt'

Looking at the output of the last command, it seems it is trying to write to /data/.Trash-1006. However, this directory does not exist. Rather, I have /data/naman/.Trash-1006. I don't have sudo access on this machine. So would it be possible to trash/put the deleted contents in my user directory on the same volume, say /data/naman/.Trash-1006 or /data/naman/.local/share/Trash.

Once again, thanks for all the help!

Naman

@andreafrancia
Copy link
Owner Author

I cannot understand why it does not use directly the home trash dir (/home/naman/.local/share/Trash).
The --verbose option does not emit sufficient data to understand the current situation.

Please, try to use this command:

trash-put --verbose --trash-dir=/home/naman/.local/share/Trash aa.txt

@bnaman50
Copy link

Hey @andreafrancia,

Here is the output
image

I think this is happening because the file aa.txt is on different disk (\data)

@andreafrancia
Copy link
Owner Author

Please try this, please:

ls ~/.local/share/Trash/files/aa.txt

Try also to trash a file named bb.txt, please

@bnaman50
Copy link

Hey @andreafrancia,

I did not have any file named bb.txt so I created one in the \data disk but the issue remains.

image

If I create the file bb.txt in my home dir, trash-put as expected.
image

Thanks,
Naman

@andreafrancia
Copy link
Owner Author

I think we're almost there, try this:

$ ls -lad /data/aa.txt
$ ls -lad /data

@bnaman50
Copy link

Hey @andreafrancia ,

Here are the results -
image

Just to clarify again, I only access to a directory in /data disk which /data/naman.
image

Thanks,
Naman

@andreafrancia
Copy link
Owner Author

ok, I was wrong about the path of aa.txt.
I think the issue can be related to the ACLs of the file.
Try this please:

$ getfacl /data/naman/aa.txt
$ getfacl /data/naman
$ getfacl /data

@bnaman50
Copy link

@andreafrancia

image

image

image

@andreafrancia
Copy link
Owner Author

Can you also try the folllowings?

$ cd /data/naman
$ touch cc.txt
$ ls -lad cc.txt
$ getfacl /data/naman/cc.txt`
$ mkdir -p /data/naman/tmp-trash
$ mv -v aa.txt /data/naman/tmp-trash 
$ mv -v cc.txt /data/naman/tmp-trash 

@bnaman50
Copy link

Hey @andreafrancia ,

This is working as expected but I don't think it solves the trash-put issue though.

image

Thanks,
Naman

@andreafrancia
Copy link
Owner Author

andreafrancia commented Sep 13, 2022

Hi @bnaman50,
it's not a permission issue.

Please try this:

$ ls /home/naman/.local/share/Trash/files/aa*
$ ls /home/naman/.local/share/Trash/info/aa*

Please redact any output line with sensible information.

Thank you
Andrea

@bnaman50
Copy link

Hey @andreafrancia,

It shows that there is no file named aa* in the location you specified.

image

And this is expected since when we moved the file over here /data/naman/tmp-trash following there commands.

Thanks,
Naman

@andreafrancia
Copy link
Owner Author

Hi @bnaman50.
Sorry for the delay.
I know we moved the source file to the /data/naman/tmp-trash. Sometimes the trash-put fails because there is already a similar named file in ~/.local/share/Trash/files but a similar named file is not present in the ~/.local/share/Trash/info directory. This is why asked you to check the directories in ~/.local/share/Trash.

I've added some other debug messages to trash-put. You need to uninstall the current version of trash-cli and install the latest version for using them:

pip uninstall trash-cli
pip install git+https://github.com/andreafrancia/trash-cli

The try to trash aa.txt using the debug option: -vv (with two "v"):

trash-put -vv aa.txt

Some other ideas: The aa.txt file is the only one that does not work? What happen if you rename the file?

@bnaman50
Copy link

Hey @andreafrancia ,

Sorry, I got busy and could not try out the solution. Here is the update -

I reinstalled it as you suggested. I also tried the command and here is the log -
image

Seems like it is expecting the trash folder to be in /data/. However, I don't have access to it. I only have access to /data/naman.

Thanks,
Naman

@andreafrancia andreafrancia pinned this issue Sep 25, 2022
@andreafrancia
Copy link
Owner Author

There is a problem when it tries to trash it in the first trash-dir (~/.local/share/Trash), it doesn't succeed but it does not show any error message. I'm trying to refactor the make it clearer and find where is the place where it may fail and it does not show the error.

Please the next time use copy and paste of the terminal text instead if pasting an image. For me would be easier copy part of the text.

@bnaman50
Copy link

Thanks a lot for your continuous help @andreafrancia. And yes, I'll write the errors in the text form rather than image from now onwards.

Thanks,
Naman

@andreafrancia
Copy link
Owner Author

Hi,
I've read and refactored the code in order to understand what is happening on your machine.

When you trash a file from /data trash-cli considers three trash-dir candidates:

  1. /home/naman/.local/share/Trash in volume /
  2. /data/.Trash/1006 in volume /data
  3. /data/.Trash-1006 in volume /data

The you want to trash is /data/namam/bb.txt in volume /data

When trash-put starts it first take in consideration the /home/naman/.local/share/Trash dir but it does not use it because the trash dir and the file are in different volumes.
Then it tries /data/.Trash/1006 which is in the right volume, but it does not use it because the .Trash directory does not exists, this directory can be created only by the administrator following the instructions described in the README.
The it tries to use the /data/.Trash-1006 directory (which is the right volume) but it fails because you user cannot create the directory .Trash-1006 in /data.

I've updated the trash-put los in order to be more clear in cases like your.
Your problem would be solved when I implement the --home-fallback option for trash-put

@bnaman50
Copy link

bnaman50 commented Oct 5, 2022

Great. Thanks for the detailed explanation, @andreafrancia.

I'll request the admin to add the top-level trash dir and mentioned in the Readme.

However, best option would be to have trash directory at user level even for other volumes such as \data. Could you please leave it as open and only close it once you implement this feature? That way, I'll get to know that you have updated it and accordingly, I can make changes on my side.

Thanks,
Naman

@raffaem
Copy link

raffaem commented Apr 10, 2023

I am experiencing a similar issue with latest git version of trash-cli:

❯ /home/raffaele/.local/bin/trash-put -vv /mnt/dataint/data/progetti_miei/raffaem.github.io/_posts/2015-03-15-formatting-and-links.md
trash-put: volume of file: /
trash-put: trying trash dir: /home/raffaele/.local/share/Trash from volume: /home
trash-put: won't use trash dir ~/.local/share/Trash because its volume (/home) in a different volume than /mnt/dataint/data/progetti_miei/raffaem.github.io/_posts/2015-03-15-formatting-and-links.md (/)
trash-put: found unusable .Trash dir (should be a dir): /.Trash
trash-put: trash directory is not secure: /.Trash/1000
trash-put: trying trash dir: /.Trash-1000 from volume: /
trash-put: failed to trash /mnt/dataint/data/progetti_miei/raffaem.github.io/_posts/2015-03-15-formatting-and-links.md in /.Trash-1000, because: [Errno 13] Permission denied: '/.Trash-1000'
trash-put: stats for /.Trash-1000: [Errno 2] No such file or directory: '/.Trash-1000'
trash-put: stats for /: 755 root root
trash-put: cannot trash regular file '/mnt/dataint/data/progetti_miei/raffaem.github.io/_posts/2015-03-15-formatting-and-links.md'

@franzhuang
Copy link

I've encountered similar issue. Irm(or mv)the ~/.local/share/Trash folder, and let trash-put create a new one by just trash-put some_file . It works so far.

@andreafrancia andreafrancia changed the title trash-put cannot trash regular empty file trash-put --home-fallback (was: trash-put cannot trash regular empty file) Nov 10, 2023
@andreafrancia
Copy link
Owner Author

@bnaman50 I'll leave open this issue until we managed to implement properly --home-fallback

@andreafrancia
Copy link
Owner Author

@raffaem I created another GitHub issue for your issue, it is here: #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants