Skip to content

Commit c43c46c

Browse files
committed
Address final prefix marker review
Signed-off-by: ABrandes <[email protected]>
1 parent 6a67af4 commit c43c46c

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/zarr/core/array.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,9 @@ async def _shards_initialized(
40204020
store_contents_relative = [
40214021
_relativize_path(path=key, prefix=array.store_path.path)
40224022
for key in store_contents
4023-
if not array.store_path.path or key != array.store_path.path
4023+
# obstore can include a directory marker whose key matches the listed prefix;
4024+
# it is not an initialized shard and must be excluded before relativizing.
4025+
if array.store_path.path == "" or key != array.store_path.path
40244026
]
40254027
return tuple(
40264028
chunk_key for chunk_key in array._iter_shard_keys() if chunk_key in store_contents_relative

‎src/zarr/storage/_obstore.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def _transform_list_dir(
267267
for path in chain(
268268
list_result["common_prefixes"], map(itemgetter("path"), list_result["objects"])
269269
):
270-
if prefix and path == prefix:
270+
if prefix != "" and path == prefix:
271271
continue
272272
relpath = _relativize_path(path=path, prefix=prefix)
273273
if relpath:

‎tests/test_store/test_object.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ async def test_store_getsize_prefix(self, store: ObjectStore[LocalStore]) -> Non
103103
re.escape("ignore:datetime.datetime.utcnow() is deprecated:DeprecationWarning")
104104
)
105105
async def test_list_dir_ignores_s3_prefix_marker(moto_server: str) -> None:
106+
"""Ensure obstore's exact-prefix S3 directory marker is not listed as a child."""
106107
boto3 = pytest.importorskip("boto3")
107108
bucket = "object-store-prefix-marker"
108109
client = boto3.client(

0 commit comments

Comments
 (0)