Move to trash from external HDs [FIXED]

Questions, glitches, bugs and crashes
Locked
gentux
Posts: 11
Joined: Thu Feb 04, 2021 6:31 pm

Move to trash from external HDs [FIXED]

Post by gentux » Sat Feb 27, 2021 7:45 am

Hi

I found a strange bug. It looks like the trash has to be "initialized" for external drives. Here's what happens:

1. I (re)boot my machine (important once it's fixed it will only happen again after reboot)
2. I move any file from an external drive to the trash using NC. Let's say File1.txt
3. I don't see File1.txt in the bin, the file is gone from the original place it looks like we deleted it completely, but actually it is in an invisible trash right now where we cannot access or even permanently delete it.
4. Now I move any file from the same external drive to trash using Finder.
5. At this point I see both File1.txt and the file I deleted using Finder.
6. From now on the trash works as expected.

I am using Catalina 10.15.7 on a Mac mini 2018 and Nimble Commander v. 1.2.9

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: Move to trash from external HDs

Post by mike » Sat Mar 06, 2021 9:16 am

Hi, thanks for pointing my attention to the issue.
The problem is that at the moment NC determines if a volume has Trash upfront, i.e. regardless of whether it could be created later by the system.
So in your case the UI is a bit different when you are dealing with a fresh drive - NC doesn't even try to move to trash, instead it says "Delete Permanently".
Once it sees a drive connected when it already has the ".Trashes" directory - it starts to offer moving to trash.

I'm still trying to figure out how to fix it without changing the existing workflow much.

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: Move to trash from external HDs

Post by mike » Sun Mar 07, 2021 12:09 am

I fixed it by opportunistically trying to trash on local volumes (not network mounts) even if the ".Trash"/".Trashes"/etc folder wasn't initialised yet.
Next preview/release build should behave correctly.

JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

Re: Move to trash from external HDs [FIXED]

Post by JayB » Sun Mar 07, 2021 4:23 pm

There is a system API for moving files to the trash: https://github.com/sindresorhus/macos-trash

I've tested the trash CLI, and the system will auto-create a .Trashes or .Trash directory, if it doesn't exist. Seems to be very simple in terms of the code.

However, it doesn't work for write-protected files. Then you'd have to escalate privileges, and then the file would wind up in /private/var/root/.Trash instead, which is not what you want.

I can't say how Finder does it, i.e. select a file belonging to root:wheel for move-to-trash, enter admin password, and the file winds up in your user's Trash, i.e. usually ~/.Trash. :?:

JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

Re: Move to trash from external HDs [FIXED]

Post by JayB » Sun Mar 07, 2021 4:29 pm

Slightly related (in terms of trash functionality): viewtopic.php?f=6&t=565

gentux
Posts: 11
Joined: Thu Feb 04, 2021 6:31 pm

Re: Move to trash from external HDs [FIXED]

Post by gentux » Tue Mar 16, 2021 10:38 pm

Thank you very much. I noticed the change and it works great for me.

Locked