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

avoid isfile calls on find as much as possible #676

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion fsspec/asyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ async def _find(self, path, maxdepth=None, withdirs=False, **kwargs):
if withdirs:
files.update(dirs)
out.update({info["name"]: info for name, info in files.items()})
if (await self._isfile(path)) and path not in out:
if not out and (await self._isfile(path)):
# walk works on directories, but find should also return [path]
# when path happens to be a file
out[path] = {}
Expand Down
2 changes: 1 addition & 1 deletion fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def find(self, path, maxdepth=None, withdirs=False, **kwargs):
if withdirs:
files.update(dirs)
out.update({info["name"]: info for name, info in files.items()})
if self.isfile(path) and path not in out:
if not out and self.isfile(path):
martindurant marked this conversation as resolved.
Show resolved Hide resolved
# walk works on directories, but find should also return [path]
# when path happens to be a file
out[path] = {}
Expand Down