Skip to content

Commit

Permalink
fix: use info() in AbstractFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
machichima committed Feb 9, 2025
1 parent cf1856a commit ff5d6bd
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions obstore/python/obstore/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,9 @@ async def _info(self, path, **kwargs):
"version": head["version"],
}
except FileNotFoundError:
# try ls, refer to the info implementation in fsspec
# https://github.com/fsspec/filesystem_spec/blob/08d1e494db177d90ccc77e5f154d5fbb34657b13/fsspec/spec.py#L643-L675
parent = self._parent(path)
out = await self._ls(parent)
out = [o for o in out if o["name"].rstrip("/") == path]
if out:
return out[0]
out = await self._ls(path)
out1 = [o for o in out if o["name"].rstrip("/") == path]
if len(out1) == 1:
if "size" not in out1[0]:
out1[0]["size"] = None
return out1[0]
elif len(out1) > 1 or out:
return {"name": path, "size": 0, "type": "directory"}
else:
raise FileNotFoundError(path)
# use info in fsspec.AbstractFileSystem
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, super().info, path, **kwargs)

async def _ls(self, path, detail=True, **kwargs):
result = await obs.list_with_delimiter_async(self.store, path)
Expand Down

0 comments on commit ff5d6bd

Please sign in to comment.