fix(tvix/castore/blobservice/chunk_rd): only skip *first* chunk bytes
When (re)initializing a chunked reader, we were erroneously skipping the first n bytes from all chunks, not just the first one. Fix this, by passing in an enumerated list of chunks, and only calling SeekFrom::Start() on the first chunk in the stream. With this, I'm able to invoke b3sum on bin/bash successfully. Change-Id: I52ea480569267e093b0ac9d6bcd5c2d1b4db25f7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11443 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
This commit is contained in:
parent
9398bc46b6
commit
28e98af9bc
1 changed files with 4 additions and 3 deletions
|
@ -209,8 +209,8 @@ where
|
|||
|
||||
let blob_service = self.blob_service.clone();
|
||||
let chunks: Vec<_> = self.chunks[start_chunk_idx..].to_vec();
|
||||
let readers_stream = tokio_stream::iter(chunks).map(
|
||||
move |(_chunk_start_offset, _chunk_size, chunk_digest)| {
|
||||
let readers_stream = tokio_stream::iter(chunks.into_iter().enumerate()).map(
|
||||
move |(nth_chunk, (_chunk_start_offset, _chunk_size, chunk_digest))| {
|
||||
let chunk_digest = chunk_digest.to_owned();
|
||||
let blob_service = blob_service.clone();
|
||||
async move {
|
||||
|
@ -223,7 +223,8 @@ where
|
|||
std::io::Error::new(std::io::ErrorKind::NotFound, "chunk not found")
|
||||
})?;
|
||||
|
||||
if skip_first_chunk_bytes > 0 {
|
||||
// iff this is the first chunk in the stream, skip by skip_first_chunk_bytes
|
||||
if nth_chunk == 0 && skip_first_chunk_bytes > 0 {
|
||||
blob_reader
|
||||
.seek(std::io::SeekFrom::Start(skip_first_chunk_bytes as u64))
|
||||
.await?;
|
||||
|
|
Loading…
Reference in a new issue