@@ -149,8 +149,10 @@ def _raise_status(self, path, status):
149
149
"""Raise error based on status."""
150
150
# 3006 - legacy (v4 errno), 17 - POSIX error, 3018 (xrootd v5 errno)
151
151
if status .errno in [3006 , 17 , 3018 ]:
152
+ if status .message .strip ().endswith ("directory not empty" ):
153
+ raise DirectoryNotEmpty (path = path , msg = status )
152
154
raise DestinationExists (path = path , msg = status )
153
- elif status .errno == 3005 :
155
+ elif status .errno in [ 3005 ] :
154
156
# Unfortunately only way to determine if the error is due to a
155
157
# directory not being empty, or that a resource is not a directory:
156
158
if status .message .strip ().endswith ("not a directory" ):
@@ -353,7 +355,7 @@ def makedir(
353
355
354
356
if not status .ok :
355
357
# 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 ]
357
359
if allow_recreate and destination_exists :
358
360
return True
359
361
self ._raise_status (path , status )
@@ -405,7 +407,7 @@ def removedir(self, path, recursive=False, force=False):
405
407
status , _ = self ._client .rmdir (self ._p (path ))
406
408
407
409
if not status .ok :
408
- directory_not_empty_error = status .errno == 3005
410
+ directory_not_empty_error = status .errno in [ 3005 , 3018 ]
409
411
if directory_not_empty_error and force :
410
412
# xrootd does not support recursive removal so do we have to
411
413
# do it ourselves.
0 commit comments