mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-04 00:07:47 +02:00
fix copy artifact accessory quota issue (#17315)
It needs to request quota for accessory on copying artifact. Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
7cf50ccc59
commit
4696f46b92
@ -623,23 +623,28 @@ func (c *controller) Walk(ctx context.Context, root *Artifact, walkFn func(*Arti
|
||||
if !walked[child.Digest] {
|
||||
queue.PushBack(child)
|
||||
}
|
||||
if len(child.Accessories) != 0 {
|
||||
for _, acc := range child.Accessories {
|
||||
accArt, err := c.Get(ctx, acc.GetData().ArtifactID, option)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !walked[accArt.Digest] {
|
||||
queue.PushBack(accArt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(artifact.Accessories) > 0 {
|
||||
var ids []int64
|
||||
for _, acc := range artifact.Accessories {
|
||||
ids = append(ids, acc.GetData().ArtifactID)
|
||||
}
|
||||
|
||||
children, err := c.List(ctx, q.New(q.KeyWords{"id__in": ids, "base": "*"}), option)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, child := range children {
|
||||
if !walked[child.Digest] {
|
||||
queue.PushBack(child)
|
||||
accArt, err := c.Get(ctx, acc.GetData().ArtifactID, option)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !walked[accArt.Digest] {
|
||||
queue.PushBack(accArt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,9 @@ func copyArtifactResources(r *http.Request, _, referenceID string) (types.Resour
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
art, err := artifactController.GetByReference(ctx, repository, reference, nil)
|
||||
art, err := artifactController.GetByReference(ctx, repository, reference, &artifact.Option{
|
||||
WithAccessory: true,
|
||||
})
|
||||
if errors.IsNotFoundErr(err) {
|
||||
// artifact not found, discontinue the API request
|
||||
return nil, errors.BadRequestError(nil).WithMessage("artifact %s not found", from)
|
||||
@ -103,7 +105,9 @@ func copyArtifactResources(r *http.Request, _, referenceID string) (types.Resour
|
||||
err = artifactController.Walk(ctx, art, func(a *artifact.Artifact) error {
|
||||
artifactDigests = append(artifactDigests, a.Digest)
|
||||
return nil
|
||||
}, nil)
|
||||
}, &artifact.Option{
|
||||
WithAccessory: true,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Errorf("walk the artifact %s failed, error: %v", art.Digest, err)
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user