oberblastmeister / trashy

a cli system trash manager, alternative to rm and trash-cli
Apache License 2.0
344 stars 12 forks source link

NixOS: trash put/restore doesn't work on mounted volumes #117

Open starlightsys opened 4 months ago

starlightsys commented 4 months ago

Trying to use trash put and trash restore on a mounted volume (mounted on for example /run/media/username/volumename/) seemingly tries to access /run/.Trash-1000 and fails. trash list however works as expected.

Setup

NixOS 24.05.20240323.44d0940 (Uakari) x86_64 nix-channel --list:

Username: username Mounted BtrFS volume named volumename

Put file in trash

Steps to reproduce

  1. Have an empty trash bin
  2. Navigate to the root directory of a mounted volume under /run such as /run/media/username/volumename/
  3. nix-shell -p trashy
  4. trash list
  5. touch test
  6. trash put test
  7. trash list

Observed

The file test is still present in the directory, and the trash bin is empty. trash list shows no files before or after.

trash put test gives this error: error: Error during a `trash` operation: Unknown { description: "Path: '\"/run/.Trash-1000\"'. Message: Permission denied (os error 13)" }

Expected

The file test is removed from the directory and is then listed with trash list.

Counterexample

  1. Have an empty trash bin
  2. Navigate to ~/
  3. nix-shell -p trashy
  4. trash list
  5. touch test
  6. trash put test
  7. trash list

Observed

The file test is removed from the directory and is then listed with trash list.

Restore file from trash

Steps to reproduce

  1. Have an empty trash bin
  2. Navigate to the root directory of a mounted volume under /run such as /run/media/username/volumename/
  3. touch test
  4. Use a file explorer to put test into the trash
  5. Confirm that test shows up in the trash bin
  6. nix-shell -p trashy
  7. trash list
  8. trash restore test
  9. Type y and Enter
  10. trash list

Observed

Both before and after trash restore, the file test shows up under the path /run/, missing the media/username/volumename/ path components. The file remains in the trash bin and does not exist in the current working directory.

trash restore test gives this error: error: Error during a `trash` operation: Unknown { description: "Path: '\"/run/test\"'. Message: Permission denied (os error 13)" }

Expected

The file test is listed with trash list, then is restored to the current working directory and is no longer listed with trash list. The trash bin is empty.

Counterexample

  1. Have an empty trash bin
  2. Navigate to ~/
  3. touch test
  4. Use a file explorer to put test into the trash
  5. Confirm that test shows up in the trash bin
  6. nix-shell -p trashy
  7. trash list
  8. trash restore test
  9. Type y and Enter
  10. trash list

Observed

The file test is listed with trash list, then is restored to the current working directory and is no longer listed with trash list. The trash bin is empty.