Giter VIP home page Giter VIP logo

Comments (12)

andreafrancia avatar andreafrancia commented on August 23, 2024 1

Thank you for your feedback, please try this new version, it should be fixed.
Let me know.

from trash-cli.

protist avatar protist commented on August 23, 2024

I've realised that this wrapper was responsible for my erroneous issue #41. The problem is that readlink -e dereferences symlinks. Instead, you can use realpath -s, which resolves mounts but not symlinks. i.e. the full command is

#!/usr/bin/env bash
# Workaround for trash-cli not being able to trash files on the *same* partition. https://github.com/andreafrancia/trash-cli/issues/38

for i in "$@"; do
  fullpath="$(realpath -s "$i")"
  fixedpath="$(echo "$fullpath" | sed "s,/HDD/$USER,$HOME/HDD,")"
  /usr/bin/trash "$fixedpath"
done

from trash-cli.

andreafrancia avatar andreafrancia commented on August 23, 2024

Does your problem still persist with the latest version of trash-cli?

from trash-cli.

protist avatar protist commented on August 23, 2024

Yes, it still persists.

from trash-cli.

andreafrancia avatar andreafrancia commented on August 23, 2024

What is the output of trash --version?

from trash-cli.

protist avatar protist commented on August 23, 2024

I was using a day-old commit (7b76dc6), but I just tested again with the latest commit (74e5f3f) and this bug is still present.

$ /usr/bin/trash --version
trash 0.17.1.1

from trash-cli.

andreafrancia avatar andreafrancia commented on August 23, 2024

Seems related to the way trash-put interprets the parent directory of foo in this particular case. But it seem also a somewhat complicated setup.

Please, tell me what is the output of this command:

readlink -f /HDD/protist/.SDDsymlinks/home/protist/.local/share/Trash

Can you paste the output of the faulty cases using the verbose option (i.e. using trash --verbose)?

Thank you

from trash-cli.

andreafrancia avatar andreafrancia commented on August 23, 2024

Please use the latest version of trash-cli (4b6aa5c), in this version trash-put prints more information when used with the verbose option.

from trash-cli.

protist avatar protist commented on August 23, 2024

Admittedly, this seems like a complicated setup, but it makes some sense. I have two drives: a small SSD (/) and a large HDD (/HDD). Hence, the quick SDD contains /, and includes most system and user directories. However, there is not enough room on the SDD for most of my working files, so my user has ~/HDD, which points to the HDD (/HDD/protist). I then also link ~/.local/share/Trash to the HDD (/HDD/protist/.SDDsymlinks/home/protist/.local/share/Trash). This is because most of the files that I trash would originally come from the HDD (~/HDD). This means trashed items are only moved, not copied to another volume. Also, this means that I don't waste space on the SDD with files scheduled to be deleted.

Hence, the path you enquired about is at its literal path.

$ readlink -f /HDD/protist/.SDDsymlinks/home/protist/.local/share/Trash
/HDD/protist/.SDDsymlinks/home/protist/.local/share/Trash

I upgraded to the latest version of trash-cli (949d4d5).

$ cd ~/HDD
$ touch foo
$ /usr/bin/trash --verbose foo
trash: Volume of file: /HDD
trash: found unusable .Trash dir (should be a dir): /HDD/.Trash
trash: Failed to trash foo in /HDD/.Trash/1000, because :[Errno 13] Permission denied: '/HDD/.Trash'
trash: Failed to trash foo in /HDD/.Trash-1000, because :[Errno 13] Permission denied: '/HDD/.Trash-1000'
trash: cannot trash regular empty file 'foo'
$ /usr/bin/trash --verbose ./foo
trash: Volume of file: /HDD
trash: found unusable .Trash dir (should be a dir): /HDD/.Trash
trash: Failed to trash ./foo in /HDD/.Trash/1000, because :[Errno 13] Permission denied: '/HDD/.Trash'
trash: Failed to trash ./foo in /HDD/.Trash-1000, because :[Errno 13] Permission denied: '/HDD/.Trash-1000'
trash: cannot trash regular empty file './foo'
$ /usr/bin/trash --verbose /HDD/protist/foo
trash: Volume of file: /HDD
trash: found unusable .Trash dir (should be a dir): /HDD/.Trash
trash: Failed to trash /HDD/protist/foo in /HDD/.Trash/1000, because :[Errno 13] Permission denied: '/HDD/.Trash'
trash: Failed to trash /HDD/protist/foo in /HDD/.Trash-1000, because :[Errno 13] Permission denied: '/HDD/.Trash-1000'
trash: cannot trash regular empty file '/HDD/protist/foo'
$ cd /HDD/protist
$ /usr/bin/trash --verbose foo
trash: Volume of file: /HDD
trash: found unusable .Trash dir (should be a dir): /HDD/.Trash
trash: Failed to trash foo in /HDD/.Trash/1000, because :[Errno 13] Permission denied: '/HDD/.Trash'
trash: Failed to trash foo in /HDD/.Trash-1000, because :[Errno 13] Permission denied: '/HDD/.Trash-1000'
trash: cannot trash regular empty file 'foo'
$ /usr/bin/trash --verbose ~/HDD/foo # works
trash: Volume of file: /home
trash: '/home/protist/HDD/foo' trashed in ~/.local/share/Trash

from trash-cli.

andreafrancia avatar andreafrancia commented on August 23, 2024

With this commit (acaaf35) I've fixed a bug that prevented trash-cli to detect the right volume when the trash directory is a link to a different volume. I'm not sure that it is enough to fix the behavior of trash-put in your setup.

Please the try again and let me know the output using --verbose.

from trash-cli.

protist avatar protist commented on August 23, 2024

I ran through the tests above that failed. These all work now.

$ cd ~/HDD
$ touch foo
$ /usr/bin/trash --verbose foo
trash: Volume of file: /HDD
trash: Trash-dir: /home/protist/.local/share/Trash from volume: /HDD
trash: 'foo' trashed in ~/.local/share/Trash
$ touch foo
$ /usr/bin/trash --verbose ./foo
trash: Volume of file: /HDD
trash: Trash-dir: /home/protist/.local/share/Trash from volume: /HDD
trash: './foo' trashed in ~/.local/share/Trash
$ touch foo
$ /usr/bin/trash --verbose /HDD/protist/foo
trash: Volume of file: /HDD
trash: Trash-dir: /home/protist/.local/share/Trash from volume: /HDD
trash: '/HDD/protist/foo' trashed in ~/.local/share/Trash
$ touch foo
$ cd /HDD/protist
$ /usr/bin/trash --verbose foo
trash: Volume of file: /HDD
trash: Trash-dir: /home/protist/.local/share/Trash from volume: /HDD
trash: 'foo' trashed in ~/.local/share/Trash

However, the one that did work before now fails.

$ /usr/bin/trash --verbose ~/HDD/foo
trash: Volume of file: /home
trash: Trash-dir: /home/protist/.local/share/Trash from volume: /HDD
trash: found unusable .Trash dir (should be a dir): /home/.Trash
trash: Trash-dir: /home/.Trash/1000 from volume: /home
trash: Failed to trash /home/protist/HDD/foo in /home/.Trash/1000, because :[Errno 13] Permission denied: '/home/.Trash'
trash: Trash-dir: /home/.Trash-1000 from volume: /home
trash: Failed to trash /home/protist/HDD/foo in /home/.Trash-1000, because :[Errno 13] Permission denied: '/home/.Trash-1000'
trash: cannot trash regular empty file '/home/protist/HDD/foo'

from trash-cli.

protist avatar protist commented on August 23, 2024

Perfect! I ran through all the tests above, and everything is fine now. Thank you!

from trash-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.