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

Function uploadWithDelete

pkg/cmd/release/shared/upload.go:146–160  ·  view source on GitHub ↗
(ctx context.Context, httpClient httpDoer, uploadURL safeurl.SafeURL, a AssetForUpload)

Source from the content-addressed store, hash-verified

144var retryInterval = time.Millisecond * 200
145
146func 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
162func uploadAsset(ctx context.Context, httpClient httpDoer, uploadURL safeurl.SafeURL, asset AssetForUpload) (*ReleaseAsset, error) {
163 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