Skip to content

Commit 6c0bb24

Browse files
authoredMar 19, 2025
fix: resolve the EOF error during push (#130)
Signed-off-by: chlins <[email protected]>
1 parent 3b027df commit 6c0bb24

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎pkg/backend/push.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"crypto/tls"
2323
"encoding/json"
2424
"fmt"
25+
"io"
2526
"net/http"
2627

2728
internalpb "github.com/CloudNativeAI/modctl/internal/pb"
@@ -178,7 +179,11 @@ func pushIfNotExist(ctx context.Context, pb *internalpb.ProgressBar, prompt stri
178179
}
179180

180181
reader := pb.Add(prompt, desc.Digest.String(), desc.Size, content)
181-
if err := dst.Blobs().Push(ctx, desc, reader); err != nil {
182+
// resolve issue: https://github.com/CloudNativeAI/modctl/issues/50
183+
// wrap the content to the NopCloser, because the implementation of the distribution will
184+
// always return the error when Close() is called.
185+
// refer: https://github.com/distribution/distribution/blob/63d3892315c817c931b88779399a8e9142899a8e/registry/storage/filereader.go#L105
186+
if err := dst.Blobs().Push(ctx, desc, io.NopCloser(reader)); err != nil {
182187
pb.Complete(desc.Digest.String(), fmt.Sprintf("Failed to push blob %s, err: %v", desc.Digest.String(), err))
183188
return err
184189
}

0 commit comments

Comments
 (0)