arsenetar / send2trash

Python library to natively send files to Trash (or Recycle bin) on all platforms.
BSD 3-Clause "New" or "Revised" License
275 stars 44 forks source link

'OSError: Directory not found' when trying to trash file in network drive #10

Open edmundchong opened 7 years ago

edmundchong commented 7 years ago

I am trying to use send2trash on a Mac OS X system.

when I try send2trash(fn) I get the error OSError: Directory not found. This only occurs when trying to trash files on my network drive (the network folder is mapped to /Volumes/...).

It seems that when I try to manually move the file to trash in Finder, the file disappears completely and does not show up in Trash. I googled a little and found that OSX seems to lack support for trashing files on network volumes! (e.g. https://arstechnica.com/civis//viewtopic.php?f=19&t=1225663). I wonder if this is something that can be overcome in the send2trash code?

walksonair commented 3 years ago

I also am running into this problem:

On main computer I developed my code asking it to trash a temporary file that is on an attached external hard drive. I then move this code over to my work horse computer that mounted the very same external hard drive as a network drive. When I run Send2Trash '/Volumes/HardDrive/trashmefolder' on the work horse folder, I get the error stating

  File "/usr/local/lib/python3.9/site-packages/send2trash/plat_osx_ctypes.py", line 56, in send2trash
    check_op_result(op_result)
  File "/usr/local/lib/python3.9/site-packages/send2trash/plat_osx_ctypes.py", line 39, in check_op_result
    raise OSError(msg)

However, running same code with the same path on main computer does not produce this error.

I also can confirm Send2Trash will trash any file/folder I give it on the work horse computer that is locally mounted.

If Send2Trash accepts the path to the file, then I don't expect there to be any issues with moving my code to another computer as MacOS mounts the network drive with the same path text.

I suspect it may be some sort of Mac OS Gatekeeper or security issue...but I enabled 'Terminal' to have full disk access or for network volumes. I am not sure what else to add.

walksonair commented 3 years ago

I also am running into this problem:

On main computer I developed my code asking it to trash a temporary file that is on an attached external hard drive. I then move this code over to my work horse computer that mounted the very same external hard drive as a network drive. When I run Send2Trash '/Volumes/HardDrive/trashmefolder' on the work horse folder, I get the error stating

  File "/usr/local/lib/python3.9/site-packages/send2trash/plat_osx_ctypes.py", line 56, in send2trash
    check_op_result(op_result)
  File "/usr/local/lib/python3.9/site-packages/send2trash/plat_osx_ctypes.py", line 39, in check_op_result
    raise OSError(msg)

However, running same code with the same path on main computer does not produce this error.

I also can confirm Send2Trash will trash any file/folder I give it on the work horse computer that is locally mounted.

If Send2Trash accepts the path to the file, then I don't expect there to be any issues with moving my code to another computer as MacOS mounts the network drive with the same path text.

I suspect it may be some sort of Mac OS Gatekeeper or security issue...but I enabled 'Terminal' to have full disk access or for network volumes. I am not sure what else to add.

On further research, it's not possible to trash anything that resides on a network volume on the MacOS platform. I'd advise as such in the error message if it can be accommodated. I rescind my previous comment and withdraw this issue.