Skip to content

Commit 1a27a6c

Browse files
committed
fs: fix 3018 error code as DirNotEmpty
1 parent 07bf1cf commit 1a27a6c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

xrootdpyfs/fs.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ def _raise_status(self, path, status):
149149
"""Raise error based on status."""
150150
# 3006 - legacy (v4 errno), 17 - POSIX error, 3018 (xrootd v5 errno)
151151
if status.errno in [3006, 17, 3018]:
152+
if status.message.strip().endswith("directory not empty"):
153+
raise DirectoryNotEmpty(path=path, msg=status)
152154
raise DestinationExists(path=path, msg=status)
153-
elif status.errno == 3005:
155+
elif status.errno in [3005]:
154156
# Unfortunately only way to determine if the error is due to a
155157
# directory not being empty, or that a resource is not a directory:
156158
if status.message.strip().endswith("not a directory"):
@@ -353,7 +355,7 @@ def makedir(
353355

354356
if not status.ok:
355357
# 3018 introduced in xrootd5, 17 = POSIX error, 3006 - legacy errno
356-
destination_exists = status.errno in [3006, 3018, 17]
358+
destination_exists = status.errno in [3006, 17, 3018]
357359
if allow_recreate and destination_exists:
358360
return True
359361
self._raise_status(path, status)
@@ -405,7 +407,7 @@ def removedir(self, path, recursive=False, force=False):
405407
status, _ = self._client.rmdir(self._p(path))
406408

407409
if not status.ok:
408-
directory_not_empty_error = status.errno == 3005
410+
directory_not_empty_error = status.errno in [3005, 3018]
409411
if directory_not_empty_error and force:
410412
# xrootd does not support recursive removal so do we have to
411413
# do it ourselves.

0 commit comments

Comments
 (0)