MCPcopy
hub / github.com/cli/cli / uploadWithDelete

Function uploadWithDelete

pkg/cmd/release/shared/upload.go:145–159  ·  view source on GitHub ↗
(ctx context.Context, httpClient httpDoer, uploadURL string, a AssetForUpload)

Source from the content-addressed store, hash-verified

143var retryInterval = time.Millisecond * 200
144
145func 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
161func uploadAsset(ctx context.Context, httpClient httpDoer, uploadURL string, asset AssetForUpload) (*ReleaseAsset, error) {
162 u, err := url.Parse(uploadURL)

Callers 2

ConcurrentUploadFunction · 0.85

Calls 3

uploadAssetFunction · 0.85
deleteAssetFunction · 0.70
shouldRetryFunction · 0.70

Tested by 1