From c7b0da2622ca4eedae558e492b97223641b6fc34 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Wed, 29 Nov 2017 15:49:19 -0800 Subject: [PATCH] Use the new walk method for catalog enumeration This change is primarily to make GC faster. Signed-off-by: Sargun Dhillon --- registry/storage/blobstore.go | 4 +--- registry/storage/catalog.go | 4 ---- registry/storage/linkedblobstore.go | 8 +------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/registry/storage/blobstore.go b/registry/storage/blobstore.go index bfa41937d..9fdf52192 100644 --- a/registry/storage/blobstore.go +++ b/registry/storage/blobstore.go @@ -88,13 +88,12 @@ func (bs *blobStore) Put(ctx context.Context, mediaType string, p []byte) (distr } func (bs *blobStore) Enumerate(ctx context.Context, ingester func(dgst digest.Digest) error) error { - specPath, err := pathFor(blobsPathSpec{}) if err != nil { return err } - err = Walk(ctx, bs.driver, specPath, func(fileInfo driver.FileInfo) error { + return bs.driver.Walk(ctx, specPath, func(fileInfo driver.FileInfo) error { // skip directories if fileInfo.IsDir() { return nil @@ -114,7 +113,6 @@ func (bs *blobStore) Enumerate(ctx context.Context, ingester func(dgst digest.Di return ingester(digest) }) - return err } // path returns the canonical path for the blob identified by digest. The blob diff --git a/registry/storage/catalog.go b/registry/storage/catalog.go index 4d4149ad0..902f40c2f 100644 --- a/registry/storage/catalog.go +++ b/registry/storage/catalog.go @@ -10,10 +10,6 @@ import ( "github.com/docker/distribution/registry/storage/driver" ) -// errFinishedWalk signals an early exit to the walk when the current query -// is satisfied. -var errFinishedWalk = errors.New("finished walk") - // Returns a list, or partial list, of repositories in the registry. // Because it's a quite expensive operation, it should only be used when building up // an initial set of repositories. diff --git a/registry/storage/linkedblobstore.go b/registry/storage/linkedblobstore.go index 329163ba1..3fb1da26f 100644 --- a/registry/storage/linkedblobstore.go +++ b/registry/storage/linkedblobstore.go @@ -237,7 +237,7 @@ func (lbs *linkedBlobStore) Enumerate(ctx context.Context, ingestor func(digest. if err != nil { return err } - err = Walk(ctx, lbs.blobStore.driver, rootPath, func(fileInfo driver.FileInfo) error { + return lbs.driver.Walk(ctx, rootPath, func(fileInfo driver.FileInfo) error { // exit early if directory... if fileInfo.IsDir() { return nil @@ -273,12 +273,6 @@ func (lbs *linkedBlobStore) Enumerate(ctx context.Context, ingestor func(digest. return nil }) - - if err != nil { - return err - } - - return nil } func (lbs *linkedBlobStore) mount(ctx context.Context, sourceRepo reference.Named, dgst digest.Digest, sourceStat *distribution.Descriptor) (distribution.Descriptor, error) {