-
Notifications
You must be signed in to change notification settings - Fork 94
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
async util: handle empty dirs better #3797
Conversation
@@ -389,7 +389,7 @@ def _scandir(future, path, request): | |||
"""Callback helper for scandir().""" | |||
future.set_result([ | |||
Path(path, directory.name) | |||
for directory in request.result | |||
for directory in request.result or [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this make any difference? If I put an empty directory in ~cylc-run
then request.result
is an empty list already. (And I didn't see an error without this change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw an error where (request.result
was returning None
) in the log whilst working on cylc-uiserver so put this in to suppress it.
Perhaps it happens when you scan a non-existent directory or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, fair enough. Probably needs a comment then, because it looks weird (if you expect request.result
to always be list).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, GitHub let me create a "suggestion" and commit it to the branch 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One review will do for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant, my comment was a style violation (line too long) 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hot fix coming.
Just noticed a warning which can occur if
scandir
attempts to scan an empty directory.I think this is harmless ATM as the only use of
scandir
is workflow scanning, if a workflow dir is empty then it's not a workflow dir so can be safely skipped.Also add a small update post-#3755.