Skip to content

Store.delete has inconsistent implementations #2451

Open
@d-v-b

Description

@d-v-b

LocalStore.delete removes entire directory trees, i.e. many objects:

async def delete(self, key: str) -> None:
# docstring inherited
self._check_writable()
path = self.root / key
if path.is_dir(): # TODO: support deleting directories? shutil.rmtree?
shutil.rmtree(path)
else:
await asyncio.to_thread(path.unlink, True) # Q: we may want to raise if path is missing

MemoryStore.delete removes single keys, i.e. just one object:

async def delete(self, key: str) -> None:
# docstring inherited
self._check_writable()
try:
del self._store_dict[key]
except KeyError:
pass

We should pick one of the two options. The fact that we got this far with such skew also means that our store tests should be made more extensive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions