Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error codes #126

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
5.5.5,
5.6.1,
5.6.2,
5.6.7,
""
]

Expand Down
8 changes: 5 additions & 3 deletions xrootdpyfs/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ def _raise_status(self, path, status):
"""Raise error based on status."""
# 3006 - legacy (v4 errno), 17 - POSIX error, 3018 (xrootd v5 errno)
if status.errno in [3006, 17, 3018]:
if status.message.strip().endswith("directory not empty"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might a bit of more work, but why don't we start creating a small mapping/enum error code: code?
See here and explanation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion, I added it to our generic issue about improving errors, for now I patched it until we have some breathing room for proper solution
see #122

raise DirectoryNotEmpty(path=path, msg=status)
raise DestinationExists(path=path, msg=status)
elif status.errno == 3005:
elif status.errno in [3005]:
# 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 Down Expand Up @@ -353,7 +355,7 @@ def makedir(

if not status.ok:
# 3018 introduced in xrootd5, 17 = POSIX error, 3006 - legacy errno
destination_exists = status.errno in [3006, 3018, 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 @@ -405,7 +407,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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like that 3005 is not that error, it is a bit misleading (it was there before).

if directory_not_empty_error and force:
# xrootd does not support recursive removal so do we have to
# do it ourselves.
Expand Down
Loading