From 50b22a5f44860f21860c83cd84e3b52b3d9f54bf Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 27 Oct 2024 17:08:00 +0100 Subject: [PATCH 1/4] fix: merge-multiple artifacts were broken --- pkg/artifacts/arifacts_v4.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/artifacts/arifacts_v4.go b/pkg/artifacts/arifacts_v4.go index 1d5611b7c02..50aec687fa8 100644 --- a/pkg/artifacts/arifacts_v4.go +++ b/pkg/artifacts/arifacts_v4.go @@ -119,6 +119,12 @@ type ArtifactContext struct { Resp http.ResponseWriter } +func artifactNameToID(s string) uint64 { + h := fnv.New64a() + h.Write([]byte(s)) + return h.Sum64() +} + func (c ArtifactContext) Error(status int, _ ...interface{}) { c.Resp.WriteHeader(status) } @@ -342,7 +348,7 @@ func (r *artifactV4Routes) finalizeArtifact(ctx *ArtifactContext) { respData := FinalizeArtifactResponse{ Ok: true, - ArtifactId: 1, + ArtifactId: artifactNameToID(req.Name), } r.sendProtbufBody(ctx, &respData) } @@ -368,11 +374,12 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) { list := []*ListArtifactsResponse_MonolithArtifact{} for _, entry := range entries { - if req.NameFilter == nil || req.NameFilter.Value == entry.Name() { + id := artifactNameToID(entry.Name()) + if (req.NameFilter == nil || req.NameFilter.Value == entry.Name()) || (req.IdFilter == nil || req.IdFilter.Value == id) { data := &ListArtifactsResponse_MonolithArtifact{ Name: entry.Name(), CreatedAt: timestamppb.Now(), - DatabaseId: 1, + DatabaseId: , WorkflowRunBackendId: req.WorkflowRunBackendId, WorkflowJobRunBackendId: req.WorkflowJobRunBackendId, Size: 0, From 8e821683706b97c0dc88a24210b862a1a14f5010 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 27 Oct 2024 17:12:25 +0100 Subject: [PATCH 2/4] Update arifacts_v4.go --- pkg/artifacts/arifacts_v4.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/artifacts/arifacts_v4.go b/pkg/artifacts/arifacts_v4.go index 50aec687fa8..c51d1b18f0b 100644 --- a/pkg/artifacts/arifacts_v4.go +++ b/pkg/artifacts/arifacts_v4.go @@ -379,7 +379,7 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) { data := &ListArtifactsResponse_MonolithArtifact{ Name: entry.Name(), CreatedAt: timestamppb.Now(), - DatabaseId: , + DatabaseId: id, WorkflowRunBackendId: req.WorkflowRunBackendId, WorkflowJobRunBackendId: req.WorkflowJobRunBackendId, Size: 0, From 641b7414194a67584ffeb6f20135b696941d6dd7 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 27 Oct 2024 17:17:42 +0100 Subject: [PATCH 3/4] Update arifacts_v4.go --- pkg/artifacts/arifacts_v4.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/artifacts/arifacts_v4.go b/pkg/artifacts/arifacts_v4.go index c51d1b18f0b..1ae1811c806 100644 --- a/pkg/artifacts/arifacts_v4.go +++ b/pkg/artifacts/arifacts_v4.go @@ -84,6 +84,7 @@ import ( "encoding/base64" "errors" "fmt" + "hash/fnv" "io" "io/fs" "net/http" @@ -119,10 +120,10 @@ type ArtifactContext struct { Resp http.ResponseWriter } -func artifactNameToID(s string) uint64 { +func artifactNameToID(s string) int64 { h := fnv.New64a() h.Write([]byte(s)) - return h.Sum64() + return int64(h.Sum64()) } func (c ArtifactContext) Error(status int, _ ...interface{}) { From 1101bcc105045f0585691f487189e0f92359e005 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 27 Oct 2024 19:56:58 +0100 Subject: [PATCH 4/4] update id of delete artifact reqest --- pkg/artifacts/arifacts_v4.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/artifacts/arifacts_v4.go b/pkg/artifacts/arifacts_v4.go index 1ae1811c806..5cac9967774 100644 --- a/pkg/artifacts/arifacts_v4.go +++ b/pkg/artifacts/arifacts_v4.go @@ -450,7 +450,7 @@ func (r *artifactV4Routes) deleteArtifact(ctx *ArtifactContext) { respData := DeleteArtifactResponse{ Ok: true, - ArtifactId: 1, + ArtifactId: artifactNameToID(req.Name), } r.sendProtbufBody(ctx, &respData) }