Compare commits

...

1 Commits

Author SHA1 Message Date
Dong Chen
13f7319c09 handle edge case when a blob has been uploaded earlier 2026-02-11 09:34:00 -08:00

View File

@@ -155,6 +155,9 @@ func (u *uploader) uploadOnce(ctx context.Context, blob Blob) (int64, error) {
if err != nil {
return 0, err
}
if uploadURL == "" {
return 0, nil // blob already exists
}
// Open file
f, err := os.Open(filepath.Join(u.srcDir, digestToPath(blob.Digest)))
@@ -217,6 +220,10 @@ func (u *uploader) initUpload(ctx context.Context, blob Blob) (string, error) {
return u.initUpload(ctx, blob)
}
if resp.StatusCode == http.StatusCreated {
return "", nil // blob already exists
}
if resp.StatusCode != http.StatusAccepted {
return "", fmt.Errorf("init: status %d", resp.StatusCode)
}