From 12acdf0a6c1e56d965ac6eb395d2bce687bf22fc Mon Sep 17 00:00:00 2001 From: Edgar Lee Date: Fri, 5 Aug 2016 17:21:48 -0700 Subject: [PATCH] Stop ErrFinishedWalk from escaping from Repositories walk Signed-off-by: Edgar Lee --- registry/handlers/catalog.go | 3 +-- registry/storage/catalog.go | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/registry/handlers/catalog.go b/registry/handlers/catalog.go index 4e95bfb0..eca98468 100644 --- a/registry/handlers/catalog.go +++ b/registry/handlers/catalog.go @@ -9,7 +9,6 @@ import ( "strconv" "github.com/docker/distribution/registry/api/errcode" - "github.com/docker/distribution/registry/storage" "github.com/docker/distribution/registry/storage/driver" "github.com/gorilla/handlers" ) @@ -51,7 +50,7 @@ func (ch *catalogHandler) GetCatalog(w http.ResponseWriter, r *http.Request) { if err == io.EOF || pathNotFound { moreEntries = false - } else if err != nil && err != storage.ErrFinishedWalk { + } else if err != nil { ch.Errors = append(ch.Errors, errcode.ErrorCodeUnknown.WithDetail(err)) return } diff --git a/registry/storage/catalog.go b/registry/storage/catalog.go index 7a8a2ac6..eb669b77 100644 --- a/registry/storage/catalog.go +++ b/registry/storage/catalog.go @@ -29,6 +29,10 @@ func (reg *registry) Repositories(ctx context.Context, repos []string, last stri return 0, err } + // errFinishedWalk signals an early exit to the walk when the current query + // is satisfied. + errFinishedWalk := errors.New("finished walk") + err = Walk(ctx, reg.blobStore.driver, root, func(fileInfo driver.FileInfo) error { err := handleRepository(fileInfo, root, last, func(repoPath string) error { foundRepos = append(foundRepos, repoPath)