From 1212ffaf5ee4acd9ffa7cae4c45cd9ba86fac87e Mon Sep 17 00:00:00 2001 From: Xiaoxuan Wang Date: Wed, 27 Dec 2023 09:55:30 +0800 Subject: [PATCH] resolved some comments Signed-off-by: Xiaoxuan Wang --- content/oci/oci.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/content/oci/oci.go b/content/oci/oci.go index 36507ac37..bf6519c37 100644 --- a/content/oci/oci.go +++ b/content/oci/oci.go @@ -409,14 +409,18 @@ func (s *Store) GC(ctx context.Context) error { s.sync.RLock() defer s.sync.RUnlock() - rootpath := filepath.Join(s.root, "blobs", "sha256") + rootpath := filepath.Join(s.root, "blobs") return filepath.Walk(rootpath, func(path string, info fs.FileInfo, err error) error { if err != nil { return err } - // skip the working directory + // skip the directories if !info.IsDir() { - blobDigest := digest.NewDigestFromEncoded("sha256", info.Name()) + alg := filepath.Base(filepath.Dir(path)) + blobDigest, err := digest.Parse(fmt.Sprintf("%s:%s", alg, info.Name())) + if err != nil { + return err + } exists, desc := s.graph.ExistsInStore(blobDigest) if !exists { // remove the blob from storage if it does not exist in Store