diff --git a/src/controller/proxy/controller.go b/src/controller/proxy/controller.go index 517643727ad5..c76e801845a8 100644 --- a/src/controller/proxy/controller.go +++ b/src/controller/proxy/controller.go @@ -35,6 +35,7 @@ import ( "github.com/goharbor/harbor/src/lib/log" "github.com/goharbor/harbor/src/lib/orm" proModels "github.com/goharbor/harbor/src/pkg/project/models" + model_tag "github.com/goharbor/harbor/src/pkg/tag/model/tag" ) const ( @@ -117,7 +118,20 @@ func (c *controller) EnsureTag(ctx context.Context, art lib.ArtifactInfo, tagNam if a == nil { return fmt.Errorf("the artifact is not ready yet, failed to tag it to %v", tagName) } - return tag.Ctl.Ensure(ctx, a.RepositoryID, a.Artifact.ID, tagName) + if err := tag.Ctl.Ensure(ctx, a.RepositoryID, a.Artifact.ID, tagName); err != nil { + return err + } + // update the pull time of tag for the first time cache + if err := tag.Ctl.Update(ctx, &tag.Tag{ + Tag: model_tag.Tag{ + RepositoryID: a.RepositoryID, + Name: tagName, + PullTime: time.Now(), + }, + }, "PullTime"); err != nil { + return err + } + return nil } func (c *controller) UseLocalBlob(ctx context.Context, art lib.ArtifactInfo) bool {