From 01a5cbba6d9d9f425f045b58fa16d8c85804c29c Mon Sep 17 00:00:00 2001 From: Brenna N Epp Date: Mon, 8 Jul 2024 16:54:39 -0700 Subject: [PATCH] fix(storage/transfermanager): correct Attrs.StartOffset for sharded downloads (#10512) Because the download is in pieces, the StartOffset may be incorrect. --- storage/transfermanager/downloader.go | 6 ++++++ storage/transfermanager/integration_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/storage/transfermanager/downloader.go b/storage/transfermanager/downloader.go index d0694d9b75c8..b29f1ee40eb2 100644 --- a/storage/transfermanager/downloader.go +++ b/storage/transfermanager/downloader.go @@ -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) } diff --git a/storage/transfermanager/integration_test.go b/storage/transfermanager/integration_test.go index 815d036dd6fb..a2ab3a9dac7e 100644 --- a/storage/transfermanager/integration_test.go +++ b/storage/transfermanager/integration_test.go @@ -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) {