| 143 | var retryInterval = time.Millisecond * 200 |
| 144 | |
| 145 | func uploadWithDelete(ctx context.Context, httpClient httpDoer, uploadURL string, a AssetForUpload) error { |
| 146 | if a.ExistingURL != "" { |
| 147 | if err := deleteAsset(ctx, httpClient, a.ExistingURL); err != nil { |
| 148 | return err |
| 149 | } |
| 150 | } |
| 151 | bo := backoff.NewConstantBackOff(retryInterval) |
| 152 | return backoff.Retry(func() error { |
| 153 | _, err := uploadAsset(ctx, httpClient, uploadURL, a) |
| 154 | if err == nil || shouldRetry(err) { |
| 155 | return err |
| 156 | } |
| 157 | return backoff.Permanent(err) |
| 158 | }, backoff.WithContext(backoff.WithMaxRetries(bo, 3), ctx)) |
| 159 | } |
| 160 | |
| 161 | func uploadAsset(ctx context.Context, httpClient httpDoer, uploadURL string, asset AssetForUpload) (*ReleaseAsset, error) { |
| 162 | u, err := url.Parse(uploadURL) |