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

Function uploadWithDelete

pkg/cmd/release/shared/upload.go:141–155  ·  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

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