Skip to content

Commit

Permalink
fix(storage/transfermanager): correct Attrs.StartOffset for sharded d…
Browse files Browse the repository at this point in the history
…ownloads (#10512)

Because the download is in pieces, the StartOffset may be incorrect.
  • Loading branch information
BrennaEpp authored Jul 8, 2024
1 parent 09a467d commit 01a5cbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions storage/transfermanager/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ func (d *Downloader) gatherShards(in *DownloadObjectInput, outs <-chan *Download
if len(errs) != 0 {
shardOut.Err = fmt.Errorf("download shard errors:\n%w", errors.Join(errs...))
}
if shardOut.Attrs != nil {
shardOut.Attrs.StartOffset = 0
if in.Range != nil {
shardOut.Attrs.StartOffset = in.Range.Offset
}
}
d.addResult(in, shardOut)
}

Expand Down
4 changes: 4 additions & 0 deletions storage/transfermanager/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ func TestIntegration_DownloaderSynchronous(t *testing.T) {
if got, want := got.Attrs.Size, tb.objectSizes[got.Object]; want != got {
t.Errorf("expected object size %d, got %d", want, got)
}

if got, want := got.Attrs.StartOffset, int64(0); want != got {
t.Errorf("expected start offset %d, got %d", want, got)
}
}

if len(results) != len(objects) {
Expand Down

0 comments on commit 01a5cbb

Please sign in to comment.