-
Notifications
You must be signed in to change notification settings - Fork 197
fix: CarStream should support large data blocks like F3 snap #6099
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e719616
fix: CarStream should support large data blocks like F3 snap
hanabi1224 33de38e
Merge branch 'main' into hm/fix-car-stream
hanabi1224 17805c5
fix ut
hanabi1224 5915703
UviBytes set_max_len to 8GiB
hanabi1224 c64da20
MAX_LEN const
hanabi1224 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ impl<ReaderT: AsyncBufRead + Unpin> CarStream<ReaderT> { | |
| .as_ref() | ||
| .map(|h| h.data_size as u64) | ||
| .unwrap_or(u64::MAX); | ||
| let mut reader = FramedRead::new(reader.take(max_car_v1_bytes), UviBytes::default()); | ||
| let mut reader = FramedRead::new(reader.take(max_car_v1_bytes), uvi_bytes()); | ||
| let header_v1 = read_v1_header(&mut reader) | ||
| .await | ||
| .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "invalid v1 header block"))?; | ||
|
|
@@ -283,7 +283,7 @@ impl<W: AsyncWrite> CarWriter<W> { | |
| let car_header = CarV1Header { roots, version: 1 }; | ||
|
|
||
| let mut header_uvi_frame = BytesMut::new(); | ||
| UviBytes::default().encode(Bytes::from(to_vec(&car_header)?), &mut header_uvi_frame)?; | ||
| uvi_bytes().encode(Bytes::from(to_vec(&car_header)?), &mut header_uvi_frame)?; | ||
|
|
||
| Ok(Self { | ||
| inner: writer, | ||
|
|
@@ -329,6 +329,12 @@ async fn read_v1_header<ReaderT: AsyncRead + Unpin>( | |
| Some(header) | ||
| } | ||
|
|
||
| pub fn uvi_bytes() -> UviBytes { | ||
| let mut decoder = UviBytes::default(); | ||
| decoder.set_max_len(usize::MAX); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this reasoanble? Shouldn't we still put some bounds on it, like at most 4 GiB?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Made it 8GiB which is reasonably large |
||
| decoder | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use std::io::Cursor; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
UviBytes::defaultcannot be banned in.clippy.tomlbecause it does not belong toUviBytes