MCPcopy Create free account
hub / github.com/cli/cli / uploadWithDelete

Function uploadWithDelete

pkg/cmd/release/shared/upload.go:142–156  ·  view source on GitHub ↗
(ctx context.Context, httpClient *http.Client, hostname string, uploadURL safeurl.SafeURL, a AssetForUpload)

Source from the content-addressed store, hash-verified

140var retryInterval = time.Millisecond * 200
141
142func 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
158func uploadAsset(ctx context.Context, httpClient *http.Client, uploadURL safeurl.SafeURL, asset AssetForUpload) (*ReleaseAsset, error) {
159 u, err := url.Parse(uploadURL.String())

Callers 2

ConcurrentUploadFunction · 0.85

Calls 4

uploadAssetFunction · 0.85
deleteAssetFunction · 0.70
shouldRetryFunction · 0.70
StringMethod · 0.65

Tested by 1