diff --git a/s3fs/core.py b/s3fs/core.py index a4a3691f..02ae0c45 100644 --- a/s3fs/core.py +++ b/s3fs/core.py @@ -853,7 +853,7 @@ async def _find( # return super().find(path) # # else: we refresh anyway, having at least two missing trees out = await self._lsdir(path, delimiter="", prefix=prefix, **kwargs) - if not out and key: + if (not out and key) and not prefix: try: out = [await self._info(path)] except FileNotFoundError: diff --git a/s3fs/tests/test_s3fs.py b/s3fs/tests/test_s3fs.py index 612db73f..e7fc621b 100644 --- a/s3fs/tests/test_s3fs.py +++ b/s3fs/tests/test_s3fs.py @@ -2535,6 +2535,7 @@ def test_find_with_prefix(s3): s3.touch(test_bucket_name + "/prefixes2") assert len(s3.find(test_bucket_name + "/prefixes")) == 100 assert len(s3.find(test_bucket_name, prefix="prefixes")) == 101 + assert len(s3.find(test_bucket_name + "/prefixes", prefix="test2_")) == 0 assert len(s3.find(test_bucket_name + "/prefixes/test_")) == 0 assert len(s3.find(test_bucket_name + "/prefixes", prefix="test_")) == 100