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