forked from TrueCloudLab/distribution
Blobwriter: call BlobWriter.Size after BlobWriter.Close
Signed-off-by: Arthur Baars <arthur@semmle.com>
This commit is contained in:
parent
1d782c38f2
commit
0490ff450b
2 changed files with 2 additions and 4 deletions
|
@ -134,7 +134,6 @@ func (buh *blobUploadHandler) StartBlobUpload(w http.ResponseWriter, r *http.Req
|
||||||
}
|
}
|
||||||
|
|
||||||
buh.Upload = upload
|
buh.Upload = upload
|
||||||
defer buh.Upload.Close()
|
|
||||||
|
|
||||||
if err := buh.blobUploadResponse(w, r, true); err != nil {
|
if err := buh.blobUploadResponse(w, r, true); err != nil {
|
||||||
buh.Errors = append(buh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))
|
buh.Errors = append(buh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))
|
||||||
|
@ -224,11 +223,8 @@ func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *ht
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
size := buh.Upload.Size()
|
|
||||||
|
|
||||||
desc, err := buh.Upload.Commit(buh, distribution.Descriptor{
|
desc, err := buh.Upload.Commit(buh, distribution.Descriptor{
|
||||||
Digest: dgst,
|
Digest: dgst,
|
||||||
Size: size,
|
|
||||||
|
|
||||||
// TODO(stevvooe): This isn't wildly important yet, but we should
|
// TODO(stevvooe): This isn't wildly important yet, but we should
|
||||||
// really set the mediatype. For now, we can let the backend take care
|
// really set the mediatype. For now, we can let the backend take care
|
||||||
|
@ -293,6 +289,7 @@ func (buh *blobUploadHandler) blobUploadResponse(w http.ResponseWriter, r *http.
|
||||||
// TODO(stevvooe): Need a better way to manage the upload state automatically.
|
// TODO(stevvooe): Need a better way to manage the upload state automatically.
|
||||||
buh.State.Name = buh.Repository.Named().Name()
|
buh.State.Name = buh.Repository.Named().Name()
|
||||||
buh.State.UUID = buh.Upload.ID()
|
buh.State.UUID = buh.Upload.ID()
|
||||||
|
buh.Upload.Close()
|
||||||
buh.State.Offset = buh.Upload.Size()
|
buh.State.Offset = buh.Upload.Size()
|
||||||
buh.State.StartedAt = buh.Upload.StartedAt()
|
buh.State.StartedAt = buh.Upload.StartedAt()
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ func (bw *blobWriter) Commit(ctx context.Context, desc distribution.Descriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
bw.Close()
|
bw.Close()
|
||||||
|
desc.Size = bw.Size()
|
||||||
|
|
||||||
canonical, err := bw.validateBlob(ctx, desc)
|
canonical, err := bw.validateBlob(ctx, desc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue