Skip to content

Commit 8017d6b

Browse files
committed
obstore delete_dir
1 parent a0c56fb commit 8017d6b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/zarr/storage/_obstore.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Store,
1414
SuffixByteRequest,
1515
)
16+
from zarr.core.common import concurrent_map
1617
from zarr.core.config import config
1718

1819
if TYPE_CHECKING:
@@ -196,6 +197,15 @@ async def delete(self, key: str) -> None:
196197
with contextlib.suppress(FileNotFoundError):
197198
await obs.delete_async(self.store, key)
198199

200+
async def delete_dir(self, prefix: str) -> None:
201+
# docstring inherited
202+
self._check_writable()
203+
if prefix != "" and not prefix.endswith("/"):
204+
prefix += "/"
205+
206+
keys = [(k,) async for k in self.list_prefix(prefix)]
207+
await concurrent_map(keys, self.delete, limit=config.get("async.concurrency"))
208+
199209
@property
200210
def supports_partial_writes(self) -> bool:
201211
# docstring inherited

0 commit comments

Comments
 (0)