When a blob upload is committed prevent writing out hashstate in the
subsequent close. When a blob upload is cancelled close the blobwriter before removing upload state to ensure old hashstates don't persist. Signed-off-by: Richard Scothern <richard.scothern@docker.com>
This commit is contained in:
parent
406d03bdb0
commit
2a2577d7b1
2 changed files with 29 additions and 3 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/docker/distribution/registry/storage/cache/memory"
|
||||
"github.com/docker/distribution/registry/storage/driver/inmemory"
|
||||
"github.com/docker/distribution/testutil"
|
||||
"path"
|
||||
)
|
||||
|
||||
// TestWriteSeek tests that the current file size can be
|
||||
|
@ -83,6 +84,15 @@ func TestSimpleBlobUpload(t *testing.T) {
|
|||
t.Fatalf("unexpected error during upload cancellation: %v", err)
|
||||
}
|
||||
|
||||
// get the enclosing directory
|
||||
uploadPath := path.Dir(blobUpload.(*blobWriter).path)
|
||||
|
||||
// ensure state was cleaned up
|
||||
_, err = driver.List(ctx, uploadPath)
|
||||
if err == nil {
|
||||
t.Fatal("files in upload path after cleanup")
|
||||
}
|
||||
|
||||
// Do a resume, get unknown upload
|
||||
blobUpload, err = bs.Resume(ctx, blobUpload.ID())
|
||||
if err != distribution.ErrBlobUploadUnknown {
|
||||
|
@ -128,6 +138,13 @@ func TestSimpleBlobUpload(t *testing.T) {
|
|||
t.Fatalf("unexpected error finishing layer upload: %v", err)
|
||||
}
|
||||
|
||||
// ensure state was cleaned up
|
||||
uploadPath = path.Dir(blobUpload.(*blobWriter).path)
|
||||
_, err = driver.List(ctx, uploadPath)
|
||||
if err == nil {
|
||||
t.Fatal("files in upload path after commit")
|
||||
}
|
||||
|
||||
// After finishing an upload, it should no longer exist.
|
||||
if _, err := bs.Resume(ctx, blobUpload.ID()); err != distribution.ErrBlobUploadUnknown {
|
||||
t.Fatalf("expected layer upload to be unknown, got %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue