Skip to content

Commit

Permalink
Attempt to accelerate _isdir (fsspec#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesgb authored Aug 27, 2021
1 parent 1828696 commit 12d7add
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions adlfs/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,26 +1327,13 @@ async def _isdir(self, path):
if fp["name"] != path:
return True
try:
container_name, path = self.split_path(path)
if not path:
container_name, path_ = self.split_path(path)
if not path_:
return await self._container_exists(container_name)
else:
path = path.strip("/")
key = path + "/"
key_length = len(key)
async with self.service_client.get_container_client(
container_name
) as cc:
blob_pages = cc.list_blobs(name_starts_with=key)
async for blob in blob_pages:
if (blob["metadata"].get("is_directory", None) == "true") and (
blob["name"] == path
):
return True
if (blob.name[:key_length] == key) and (
len(blob["name"]) > len(key)
):
return True
if await self._exists(path) and not await self._isfile(path):
return True
else:
return False
except IOError:
return False
Expand Down

0 comments on commit 12d7add

Please sign in to comment.