Skip to content

Commit

Permalink
chore: reduce number of spurious log messages produced by GetNextDige…
Browse files Browse the repository at this point in the history
…stWithBlobPaths

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 <[email protected]>
  • Loading branch information
andaaron committed Oct 14, 2024
1 parent a10c5fa commit 443882b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions pkg/storage/imagestore/imagestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 443882b

Please sign in to comment.