Skip to content

Commit

Permalink
fs: fix 3018 error code as DirNotEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
kpsherva committed Feb 13, 2024
1 parent 0275865 commit 16dfc0d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions xrootdpyfs/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _raise_status(self, path, status):
# 3006 - legacy (v4 errno), 17 - POSIX error, 3018 (xrootd v5 errno)
if status.errno in [3006, 17]:
raise DestinationExists(path=path, msg=status)
elif status.errno == 3005:
elif status.errno in [3005, 3018]:
# Unfortunately only way to determine if the error is due to a
# directory not being empty, or that a resource is not a directory:
if status.message.strip().endswith("not a directory"):
Expand All @@ -159,8 +159,6 @@ def _raise_status(self, path, status):
raise DirectoryNotEmpty(path=path, msg=status)
elif status.errno == 3011:
raise ResourceNotFound(path=path, msg=status)
elif status.errno == 3018:
raise DirectoryNotEmpty(path=path, msg=status)
else:
raise ResourceError(path=path, msg=status)

Expand Down Expand Up @@ -355,7 +353,7 @@ def makedir(

if not status.ok:
# 3018 introduced in xrootd5, 17 = POSIX error, 3006 - legacy errno
destination_exists = status.errno in [3006, 17]
destination_exists = status.errno in [3006, 17, 3018]
if allow_recreate and destination_exists:
return True
self._raise_status(path, status)
Expand Down Expand Up @@ -407,7 +405,7 @@ def removedir(self, path, recursive=False, force=False):
status, _ = self._client.rmdir(self._p(path))

if not status.ok:
directory_not_empty_error = status.errno == 3005
directory_not_empty_error = status.errno in [3005, 3018]
if directory_not_empty_error and force:
# xrootd does not support recursive removal so do we have to
# do it ourselves.
Expand Down

0 comments on commit 16dfc0d

Please sign in to comment.