Merge pull request #7641 from thaJeztah/fix_usage_of_deprecated_funcs
Remove uses of deprecated go-digest.NewDigestFromHex, go-digest.Digest.Hex
This commit is contained in:
commit
3fd52c852f
@ -262,7 +262,7 @@ func (s *store) Walk(ctx context.Context, fn content.WalkFunc, fs ...string) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dgst := digest.NewDigestFromHex(alg.String(), filepath.Base(path))
|
dgst := digest.NewDigestFromEncoded(alg, filepath.Base(path))
|
||||||
if err := dgst.Validate(); err != nil {
|
if err := dgst.Validate(); err != nil {
|
||||||
// log error but don't report
|
// log error but don't report
|
||||||
log.L.WithError(err).WithField("path", path).Error("invalid digest for blob path")
|
log.L.WithError(err).WithField("path", path).Error("invalid digest for blob path")
|
||||||
@ -628,14 +628,14 @@ func (s *store) blobPath(dgst digest.Digest) (string, error) {
|
|||||||
return "", fmt.Errorf("cannot calculate blob path from invalid digest: %v: %w", err, errdefs.ErrInvalidArgument)
|
return "", fmt.Errorf("cannot calculate blob path from invalid digest: %v: %w", err, errdefs.ErrInvalidArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Hex()), nil
|
return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Encoded()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *store) ingestRoot(ref string) string {
|
func (s *store) ingestRoot(ref string) string {
|
||||||
// we take a digest of the ref to keep the ingest paths constant length.
|
// we take a digest of the ref to keep the ingest paths constant length.
|
||||||
// Note that this is not the current or potential digest of incoming content.
|
// Note that this is not the current or potential digest of incoming content.
|
||||||
dgst := digest.FromString(ref)
|
dgst := digest.FromString(ref)
|
||||||
return filepath.Join(s.root, "ingest", dgst.Hex())
|
return filepath.Join(s.root, "ingest", dgst.Encoded())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ingestPaths are returned. The paths are the following:
|
// ingestPaths are returned. The paths are the following:
|
||||||
|
@ -308,7 +308,7 @@ func checkBlobPath(t *testing.T, cs content.Store, dgst digest.Digest) string {
|
|||||||
t.Fatalf("failed to calculate blob path: %v", err)
|
t.Fatalf("failed to calculate blob path: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Hex()) {
|
if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Encoded()) {
|
||||||
t.Fatalf("unexpected path: %q", path)
|
t.Fatalf("unexpected path: %q", path)
|
||||||
}
|
}
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
|
@ -40,7 +40,7 @@ func checkBlobPath(dgst digest.Digest, root string) error {
|
|||||||
if err := dgst.Validate(); err != nil {
|
if err := dgst.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
path := filepath.Join(root, "blobs", dgst.Algorithm().String(), dgst.Hex())
|
path := filepath.Join(root, "blobs", dgst.Algorithm().String(), dgst.Encoded())
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user