-
Notifications
You must be signed in to change notification settings - Fork 254
fix(iroh-store): put_many
bug
#507
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
Conversation
e562342
to
05ead87
Compare
- `continue` instead of `return`, when we find that a CID already exists in the store - ensure we aren't double-adding CIDs from the same batch, by tracking the batched CIDs in a HashSet
05ead87
to
18748ed
Compare
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.
See the comments for some minor improvements
@@ -367,9 +367,9 @@ impl<'a> WriteStore<'a> { | |||
let mut total_blob_size = 0; | |||
|
|||
let mut batch = WriteBatch::default(); | |||
let mut cid_tracker: HashSet<Cid> = std::collections::HashSet::default(); | |||
let mut cid_tracker: AHashSet<Cid> = AHashSet::default(); |
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.
If we had a vec we could use https://docs.rs/ahash/latest/ahash/struct.AHashSet.html#method.with_capacity here to make sure the hashset does not need to rehash.
But with the iterator we could just use the size hint, which is probably not worth it.
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.
HashSet
s have with_capacity
: https://docs.rs/ahash/latest/ahash/struct.AHashSet.html#method.with_capacity
Fixes the following scenario: if you attempt to add a folder with some files, it adds fine. But if you add a new file to that folder and add it again, the store won't add the new file.
closes n0-computer/beetle#114