uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

ProperPath remove method cannot remove directory if the directory is inside path of kind 'dir' #135

Closed mhxion closed 2 months ago

mhxion commented 3 months ago
$ lt ~/foo

/Users/<username>/foo
├── bar
│  ├── foobar
│  ├── iow
│  └── zoo
└── tmp.txt

Now running ProperPath("~/foo").remove() will throw:

>>> p.kind
'dir'
>>> p.remove()
WARNING  Permission to remove PATH=/Users/culdesac/foo/bar from SOURCE=~/foo is denied.                                           path.py:196
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/culdesac/Workshop/elapi_frontend_plugin/.venv/lib/python3.9/site-packages/elapi/path.py", line 215, in remove
    self._remove_file(_file=ref, verbose=verbose)
  File "/Users/culdesac/Workshop/elapi_frontend_plugin/.venv/lib/python3.9/site-packages/elapi/path.py", line 198, in _remove_file
    raise e
  File "/Users/culdesac/Workshop/elapi_frontend_plugin/.venv/lib/python3.9/site-packages/elapi/path.py", line 189, in _remove_file
    file.unlink()
  File "/opt/homebrew/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 1354, in unlink
    self._accessor.unlink(self)
PermissionError: [Errno 1] Operation not permitted: '/Users/culdesac/foo/bar'