Skip to content

Fix erroneous .unwrap() #228

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

Closed
matheus23 opened this issue Apr 3, 2023 · 0 comments · Fixed by #252
Closed

Fix erroneous .unwrap() #228

matheus23 opened this issue Apr 3, 2023 · 0 comments · Fixed by #252
Labels
bug Something isn't working

Comments

@matheus23
Copy link
Member

Summary

An .unwrap() in the PrivateFile implementation can panic, if the blockstore doesn't contain the blocks to read the file.

Solution

We should just propagate out the result in this function:

pub async fn get_content(
&self,
forest: &PrivateForest,
store: &impl BlockStore,
) -> Result<Vec<u8>> {
let mut content = Vec::with_capacity(self.get_content_size_upper_bound());
self.stream_content(0, forest, store)
.for_each(|chunk| {
content.extend_from_slice(&chunk.unwrap());
future::ready(())
})
.await;
Ok(content)
}

There's TryStreamExt. It may have some functions to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants