Skip to content

Commit

Permalink
fix: Cleanup multi-part session & layer parts after upload
Browse files Browse the repository at this point in the history
Signed-off-by: jay-dee7 <[email protected]>
  • Loading branch information
jay-dee7 committed Nov 26, 2023
1 parent b1f5c39 commit 6918b9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dfs/ipfs/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (ipfs *ipfsP2p) CompleteMultipartUpload(
}
}

// cleanup session & cached layer parts
ipfs.uploadSession.Del(uploadId)
ipfs.uploadParts.Del(uploadId)

return path.RootCid().String(), nil
}

Expand Down
18 changes: 15 additions & 3 deletions registry/v2/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ func (r *registry) MonolithicUpload(ctx echo.Context) error {
imageDigest := ctx.QueryParam("digest")
buf := &bytes.Buffer{}
if _, err := io.Copy(buf, ctx.Request().Body); err != nil {
errMsg := common.RegistryErrorResponse(RegistryErrorCodeBlobUploadInvalid, "error while reading request body", nil)
errMsg := common.RegistryErrorResponse(
RegistryErrorCodeBlobUploadInvalid,
"error while reading request body",
nil,
)
echoErr := ctx.JSONBlob(http.StatusNotFound, errMsg.Bytes())
r.logger.Log(ctx, fmt.Errorf("%s", errMsg)).Send()
return echoErr
Expand Down Expand Up @@ -522,7 +526,11 @@ func (r *registry) MonolithicPut(ctx echo.Context) error {

txnOp, ok := r.txnMap[uploadID]
if !ok {
errMsg := common.RegistryErrorResponse(RegistryErrorCodeUnknown, "transaction does not exist for uuid -"+identifier, nil)
errMsg := common.RegistryErrorResponse(
RegistryErrorCodeUnknown,
"transaction does not exist for uuid -"+identifier,
nil,
)
echoErr := ctx.JSONBlob(http.StatusBadRequest, errMsg.Bytes())
r.logger.Log(ctx, fmt.Errorf("%s", errMsg)).Send()
return echoErr
Expand Down Expand Up @@ -649,7 +657,11 @@ func (r *registry) CompleteUpload(ctx echo.Context) error {

txnOp, ok := r.txnMap[uploadID]
if !ok {
errMsg := common.RegistryErrorResponse(RegistryErrorCodeUnknown, "transaction does not exist for uuid -"+identifier, nil)
errMsg := common.RegistryErrorResponse(
RegistryErrorCodeUnknown,
"transaction does not exist for uuid -"+identifier,
nil,
)
echoErr := ctx.JSONBlob(http.StatusBadRequest, errMsg.Bytes())
r.logger.Log(ctx, fmt.Errorf("%s", errMsg)).Send()
return echoErr
Expand Down

0 comments on commit 6918b9a

Please sign in to comment.