diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5a61d3d Binary files /dev/null and b/.DS_Store differ diff --git a/tosfs/core.py b/tosfs/core.py index 9464933..b90a449 100644 --- a/tosfs/core.py +++ b/tosfs/core.py @@ -442,6 +442,10 @@ def ls_iterate( path = self._strip_protocol(path) bucket, key, _ = self._split_path(path) + + if recursive and self._is_hns_bucket(bucket): + raise ValueError("Recursive listing is not supported for HNS bucket.") + prefix = key.lstrip("/") + "/" if key else "" continuation_token = "" is_truncated = True diff --git a/tosfs/tests/test_tosfs.py b/tosfs/tests/test_tosfs.py index 945d4bb..f7b9d6e 100644 --- a/tosfs/tests/test_tosfs.py +++ b/tosfs/tests/test_tosfs.py @@ -129,19 +129,22 @@ def test_ls_iterate( assert len(result) == len([dir_name, another_dir_name]) # Test list recursively - expected = [ - f"{bucket}/{temporary_workspace}/{dir_name}", - f"{bucket}/{temporary_workspace}/{dir_name}/{file_name}", - f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}", - f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}", - f"{bucket}/{temporary_workspace}/{another_dir_name}", - ] - result = [ - item - for batch in tosfs.ls_iterate(f"{bucket}/{temporary_workspace}", recursive=True) - for item in batch - ] - assert sorted(result) == sorted(expected) + if tosfs._is_fns_bucket(bucket): + expected = [ + f"{bucket}/{temporary_workspace}/{dir_name}", + f"{bucket}/{temporary_workspace}/{dir_name}/{file_name}", + f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}", + f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}", + f"{bucket}/{temporary_workspace}/{another_dir_name}", + ] + result = [ + item + for batch in tosfs.ls_iterate( + f"{bucket}/{temporary_workspace}", recursive=True + ) + for item in batch + ] + assert sorted(result) == sorted(expected) def test_inner_rm(tosfs: TosFileSystem, bucket: str, temporary_workspace: str) -> None: