Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/zarr/storage/_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,18 @@ def __setstate__(self, state: dict[str, Any]) -> None:

def close(self) -> None:
# docstring inherited
if not self._is_open:
self._sync_open()

super().close()
with self._lock:
self._zf.close()

async def clear(self) -> None:
# docstring inherited
if not self._is_open:
self._sync_open()

with self._lock:
self._check_writable()
self._zf.close()
Expand Down Expand Up @@ -188,6 +194,8 @@ async def get_partial_values(
key_ranges: Iterable[tuple[str, ByteRequest | None]],
) -> list[Buffer | None]:
# docstring inherited
if not self._is_open:
self._sync_open()
out = []
with self._lock:
for key, byte_range in key_ranges:
Expand Down Expand Up @@ -222,6 +230,9 @@ async def set(self, key: str, value: Buffer) -> None:

async def set_if_not_exists(self, key: str, value: Buffer) -> None:
self._check_writable()
if not self._is_open:
self._sync_open()

with self._lock:
members = self._zf.namelist()
if key not in members:
Expand All @@ -245,6 +256,9 @@ async def delete(self, key: str) -> None:

async def exists(self, key: str) -> bool:
# docstring inherited
if not self._is_open:
self._sync_open()

with self._lock:
try:
self._zf.getinfo(key)
Expand All @@ -255,6 +269,9 @@ async def exists(self, key: str) -> bool:

async def list(self) -> AsyncIterator[str]:
# docstring inherited
if not self._is_open:
self._sync_open()

with self._lock:
for key in self._zf.namelist():
yield key
Expand Down