From 8820408d0a5529e11cd5a9b26e5c7c621fefd869 Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Tue, 15 Oct 2024 19:29:01 +0300 Subject: [PATCH] chore: reduce number of spurious log messages produced by GetNextDigestWithBlobPaths (#2727) Exit early in case of all folders and known non-blob file names. This avoids the logic for validating digests, and log message generation. Signed-off-by: Andrei Aaron --- pkg/storage/imagestore/imagestore.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pkg/storage/imagestore/imagestore.go b/pkg/storage/imagestore/imagestore.go index 22db78cd7..8fe1846f4 100644 --- a/pkg/storage/imagestore/imagestore.go +++ b/pkg/storage/imagestore/imagestore.go @@ -1804,17 +1804,28 @@ func (is *ImageStore) GetNextDigestWithBlobPaths(repos []string, lastDigests []g if fileInfo.IsDir() { // skip repositories not found in repos - repo := path.Base(fileInfo.Path()) - if !zcommon.Contains(repos, repo) && repo != ispec.ImageBlobsDir { - candidateAlgorithm := godigest.Algorithm(repo) + baseName := path.Base(fileInfo.Path()) + if zcommon.Contains(repos, baseName) || baseName == ispec.ImageBlobsDir { + return nil + } - if !candidateAlgorithm.Available() { - return driver.ErrSkipDir - } + candidateAlgorithm := godigest.Algorithm(baseName) + + if !candidateAlgorithm.Available() { + return driver.ErrSkipDir } + + return nil + } + + baseName := path.Base(fileInfo.Path()) + + skippedFiles := []string{ispec.ImageLayoutFile, ispec.ImageIndexFile, "meta.db", "cache.db"} + if zcommon.Contains(skippedFiles, baseName) { + return nil } - digestHash := path.Base(fileInfo.Path()) + digestHash := baseName digestAlgorithm := godigest.Algorithm(path.Base(path.Dir(fileInfo.Path()))) blobDigest := godigest.NewDigestFromEncoded(digestAlgorithm, digestHash)