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

Trashing doesn't work across different devices (linux) #57

Open
kampffrosch94 opened this issue Oct 18, 2022 · 4 comments
Open

Trashing doesn't work across different devices (linux) #57

kampffrosch94 opened this issue Oct 18, 2022 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@kampffrosch94
Copy link

I am trashing a file in a zfs dataset different from the one my home directory is mounted in and get the following error:
Message: Invalid cross-device link (os error 18)
It seems to be a limitation of using rename.

@Byron Byron added bug Something isn't working help wanted Extra attention is needed labels Oct 18, 2022
@Byron
Copy link
Owner

Byron commented Oct 18, 2022

Thanks for letting me know. The assumption is that the trash folder is located on the same filesystem and currently there are no precautions for that.
Please also note that I didn't try to reproduce the issue, but also believe that move won't work across filesystems (when using the naive system call at least).

A decent way of fixing this would probably be to better determine the location of the trash directory, which should never be outside of the file system of the files to be trashed. I'd be interested to hear how the standard OS 'delete file' functionality handles this with details on where puts the trash directory, and how it's organized.

@ArturKovacs
Copy link
Collaborator

This might be of some help:
https://specifications.freedesktop.org/trash-spec/trashspec-latest.html

But looking at an actual implementation would possibly be more useful.

@ja0nz
Copy link

ja0nz commented Nov 12, 2022

I haven't read the source code but this is how trash-cli seems to solve this one:

Deletion / trash-put

  • if deleted file resides withing SAME mount point as /home/user -> move to ~/.local/share/Trash/files (accompanied with a ~/.local/share/Trash/info metadata record)
  • if deleted file resides in a DIFFERENT mount point file tree -> move to mntpoint/.Trash-$UID/files again with metadata record. So eventually deleted files stay in their origin partition/volume.

Listing / trash-list

Crawl all mount points for .Trash-$UID directories plus ~/.local/share/Trash and listing the files x.trashinfo metadata which contains the relavant information as absolute path:

[Trash Info]
Path=/home/user/mntpoint/to/a/subvolume
DeletionDate=2022-11-08T19:56:19

@Byron
Copy link
Owner

Byron commented Nov 12, 2022

Thanks a lot for the hints, they will certainly help with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants