Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store.delete has inconsistent implementations #2451

Open
d-v-b opened this issue Oct 30, 2024 · 1 comment
Open

Store.delete has inconsistent implementations #2451

d-v-b opened this issue Oct 30, 2024 · 1 comment

Comments

@d-v-b
Copy link
Contributor

d-v-b commented Oct 30, 2024

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.

@jhamman
Copy link
Member

jhamman commented Oct 30, 2024

Good catch! Store.delete should be for a single key. In #2430, I introduce delete_dir for removing all objects below a node in a hierarchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants