Skip to content

Commit

Permalink
fix: raise error when listing empty dir
Browse files Browse the repository at this point in the history
  • Loading branch information
john-jam committed Aug 16, 2023
1 parent 7a63104 commit 27a4085
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,8 @@ async def _ls(self, path, detail=False, refresh=False, versions=False):
for o in files
if o["name"].rstrip("/") == path and o["type"] != "directory"
]
if not files:
raise FileNotFoundError(path)
if detail:
return files
return files if detail else sorted([o["name"] for o in files])
Expand Down
3 changes: 2 additions & 1 deletion s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ def test_info(s3):
s3.mkdir(new_parent)
with pytest.raises(FileNotFoundError):
s3.info(new_parent)
s3.ls(new_parent)
with pytest.raises(FileNotFoundError):
s3.ls(new_parent)
with pytest.raises(FileNotFoundError):
s3.info(new_parent)

Expand Down

0 comments on commit 27a4085

Please sign in to comment.