From 50edaf4bc8c34c0b2b49ec0ac6c56d2e30abde6a Mon Sep 17 00:00:00 2001 From: Frederic Branczyk Date: Tue, 13 Dec 2022 11:28:21 +0100 Subject: [PATCH] pkg/debuginfo: Set size of upload in upload initiation --- pkg/debuginfo/manager.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/debuginfo/manager.go b/pkg/debuginfo/manager.go index ec7dff6609..90e34c72da 100644 --- a/pkg/debuginfo/manager.go +++ b/pkg/debuginfo/manager.go @@ -176,6 +176,7 @@ func (di *Manager) ensureUploaded(ctx context.Context, objFile *objectfile.Mappe } var r io.ReadSeeker + size := int64(0) if di.stripDebuginfos { if err := os.MkdirAll(di.tempDir, 0o755); err != nil { @@ -201,6 +202,13 @@ func (di *Manager) ensureUploaded(ctx context.Context, objFile *objectfile.Mappe if _, err := f.Seek(0, io.SeekStart); err != nil { return fmt.Errorf("failed to seek to the beginning of the file: %w", err) } + + stat, err := f.Stat() + if err != nil { + return fmt.Errorf("failed to stat the file: %w", err) + } + size = stat.Size() + r = f } else { f, err := os.Open(src) @@ -209,6 +217,12 @@ func (di *Manager) ensureUploaded(ctx context.Context, objFile *objectfile.Mappe } defer f.Close() + stat, err := f.Stat() + if err != nil { + return fmt.Errorf("failed to stat the file: %w", err) + } + size = stat.Size() + r = f } @@ -224,6 +238,7 @@ func (di *Manager) ensureUploaded(ctx context.Context, objFile *objectfile.Mappe initiateResp, err := di.debuginfoClient.InitiateUpload(ctx, &debuginfopb.InitiateUploadRequest{ BuildId: buildID, Hash: hash, + Size: size, }) if err != nil { if sts, ok := status.FromError(err); ok {