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