NOTICKET: remove layer links

This commit is contained in:
vitshev
2025-02-09 20:33:56 +01:00
parent 7271d882c0
commit 00efb5e915

View File

@@ -6,6 +6,7 @@ import (
"io" "io"
"net/http" "net/http"
"path" "path"
"reflect"
"time" "time"
"github.com/distribution/distribution/v3" "github.com/distribution/distribution/v3"
@@ -331,6 +332,12 @@ func (lbs *linkedBlobStore) linkBlob(ctx context.Context, canonical v1.Descripto
// since we don't care about the aliases. They are generally unused except // since we don't care about the aliases. They are generally unused except
// for tarsum but those versions don't care about mediatype. // for tarsum but those versions don't care about mediatype.
if reflect.ValueOf(lbs.linkPath).Pointer() == reflect.ValueOf(blobLinkPath).Pointer() {
fmt.Println("b.linkPath is blobLinkPath")
return nil
}
// Don't make duplicate links. // Don't make duplicate links.
seenDigests := make(map[digest.Digest]struct{}, len(dgsts)) seenDigests := make(map[digest.Digest]struct{}, len(dgsts))
@@ -367,6 +374,27 @@ type linkedBlobStatter struct {
var _ distribution.BlobDescriptorService = &linkedBlobStatter{} var _ distribution.BlobDescriptorService = &linkedBlobStatter{}
func (lbs *linkedBlobStatter) Stat(ctx context.Context, dgst digest.Digest) (v1.Descriptor, error) { func (lbs *linkedBlobStatter) Stat(ctx context.Context, dgst digest.Digest) (v1.Descriptor, error) {
if reflect.ValueOf(lbs.linkPath).Pointer() == reflect.ValueOf(blobLinkPath).Pointer() {
currentBlobPath, err := pathFor(blobDataPathSpec{digest: dgst})
if err != nil {
return v1.Descriptor{}, err
}
_, err = lbs.driver.Stat(ctx, currentBlobPath)
if err != nil {
switch err := err.(type) {
case driver.PathNotFoundError:
return v1.Descriptor{}, distribution.ErrBlobUnknown
default:
return v1.Descriptor{}, err
}
}
return lbs.blobStore.statter.Stat(ctx, dgst)
}
blobLinkPath, err := lbs.linkPath(lbs.repository.Named().Name(), dgst) blobLinkPath, err := lbs.linkPath(lbs.repository.Named().Name(), dgst)
if err != nil { if err != nil {
return v1.Descriptor{}, err return v1.Descriptor{}, err
@@ -394,6 +422,10 @@ func (lbs *linkedBlobStatter) Stat(ctx context.Context, dgst digest.Digest) (v1.
} }
func (lbs *linkedBlobStatter) Clear(ctx context.Context, dgst digest.Digest) (err error) { func (lbs *linkedBlobStatter) Clear(ctx context.Context, dgst digest.Digest) (err error) {
if reflect.ValueOf(lbs.linkPath).Pointer() == reflect.ValueOf(blobLinkPath).Pointer() {
return nil
}
blobLinkPath, err := lbs.linkPath(lbs.repository.Named().Name(), dgst) blobLinkPath, err := lbs.linkPath(lbs.repository.Named().Name(), dgst)
if err != nil { if err != nil {
return err return err
@@ -416,3 +448,8 @@ func blobLinkPath(name string, dgst digest.Digest) (string, error) {
func manifestRevisionLinkPath(name string, dgst digest.Digest) (string, error) { func manifestRevisionLinkPath(name string, dgst digest.Digest) (string, error) {
return pathFor(manifestRevisionLinkPathSpec{name: name, revision: dgst}) return pathFor(manifestRevisionLinkPathSpec{name: name, revision: dgst})
} }
// blobPath provides the path to the real blob
func blobPath(name string, dgst digest.Digest) (string, error) {
return pathFor(blobPathSpec{digest: dgst})
}