From 861715c81f55ddc8b0c2646003e797af293fbe85 Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Mon, 15 Mar 2021 16:53:37 +0100 Subject: [PATCH] Open release file in retry loop (#110) --- pkg/github/github.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/github/github.go b/pkg/github/github.go index cf947737..2ac51116 100644 --- a/pkg/github/github.go +++ b/pkg/github/github.go @@ -153,17 +153,17 @@ func (c *Client) uploadReleaseAsset(ctx context.Context, releaseID int64, filena return errors.Wrap(err, "failed to get abs path") } - f, err := os.Open(filename) - if err != nil { - return errors.Wrap(err, "failed to open file") - } - opts := &github.UploadOptions{ // Use base name by default Name: filepath.Base(filename), } if err := retry.Retry(3, 3*time.Second, func() error { + f, err := os.Open(filename) + if err != nil { + return errors.Wrap(err, "failed to open file") + } + defer f.Close() if _, _, err = c.Repositories.UploadReleaseAsset(context.TODO(), c.owner, c.repo, releaseID, opts, f); err != nil { return errors.Wrapf(err, "failed to upload release asset: %s\n", filename) }