-
Notifications
You must be signed in to change notification settings - Fork 164
Implement rmdir method for HNS buckets #728
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
base: main
Are you sure you want to change the base?
Conversation
|
Question: since HNS buckets have a true folder structure, it should be possible to ammend the directory listings cache rather than simply invalidate it when deleting, no? That could avoid unnecessary listings later on. |
|
/gcbrun |
63e15da to
10c8424
Compare
@martindurant Invalidating the cache for a specific path was also invalidating the cache for all parent directories in the hierarchy. I have updated the logic to remove the cache entry only for the deleted directory and to update its immediate parent to remove the deleted directory's entry. |
8a74f38 to
0e9718c
Compare
|
/gcbrun |
2 similar comments
|
/gcbrun |
|
/gcbrun |
@martindurant Can you please review the latest changes following the cache update logic? |
eb102df to
b1f396c
Compare
| for i, entry in enumerate(self.dircache[parent]): | ||
| if entry.get("name") == path: | ||
| self.dircache[parent].pop(i) | ||
| break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ought to be correct, but if some some reason the entry is duplicated in the parent, you would end up removing the wrong thing. I think a comprehension would be clearer:
| for i, entry in enumerate(self.dircache[parent]): | |
| if entry.get("name") == path: | |
| self.dircache[parent].pop(i) | |
| break | |
| self.dircache[parent] = [ent for ent in self.dircache[parent] if ent["name"] != path] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion, Initially I planned something similar to your suggestion but wanted to skip iterating over entire list if we have already removed the path from parent cache to optimize the code(might not give much performance difference though).
you would end up removing the wrong thing
Just to make sure I understand this correctly, were you referring that we will not be removing duplicate entry if it exists?
rmdir method provides an implementation for deletion of empty directories for Hierarchical Namespace (HNS) enabled buckets.