From ad69f7175af3dc6974df6ad22f22833c284456df Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 9 Aug 2023 01:21:48 +0800 Subject: [PATCH] fix artifact merging chunks path with correct slash on Windows (#26400) From Discord https://discord.com/channels/322538954119184384/1069795723178160168/1136719889684500480 Artifact chunks merging is break on Windows. ``` Gitea Log: 2023/08/03 20:51:15 ...actions/artifacts.go:271:comfirmUploadArtifact() [E] Error merge chunks: parse content range error: input does not match format ``` Artifact uses wrong slash to parse saved chunks path. --- routers/api/actions/artifacts_chunks.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/api/actions/artifacts_chunks.go b/routers/api/actions/artifacts_chunks.go index 8168377d50..30d31b4d75 100644 --- a/routers/api/actions/artifacts_chunks.go +++ b/routers/api/actions/artifacts_chunks.go @@ -8,6 +8,7 @@ import ( "encoding/base64" "fmt" "io" + "path/filepath" "sort" "time" @@ -67,7 +68,7 @@ func listChunksByRunID(st storage.ObjectStorage, runID int64) (map[int64][]*chun var chunks []*chunkFileItem if err := st.IterateObjects(storageDir, func(path string, obj storage.Object) error { item := chunkFileItem{Path: path} - if _, err := fmt.Sscanf(path, storageDir+"/%d-%d-%d.chunk", &item.ArtifactID, &item.Start, &item.End); err != nil { + if _, err := fmt.Sscanf(path, filepath.Join(storageDir, "%d-%d-%d.chunk"), &item.ArtifactID, &item.Start, &item.End); err != nil { return fmt.Errorf("parse content range error: %v", err) } chunks = append(chunks, &item)