fix: artifact v4 upload above 8MB (#2402)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
ChristopherHX
2024-09-08 01:01:50 +02:00
committed by GitHub
parent 38e43bd51f
commit 32b6bb7a25

View File

@@ -271,6 +271,16 @@ func (r *artifactV4Routes) createArtifact(ctx *ArtifactContext) {
artifactName := req.Name artifactName := req.Name
safeRunPath := safeResolve(r.baseDir, fmt.Sprint(runID))
safePath := safeResolve(safeRunPath, artifactName)
safePath = safeResolve(safePath, artifactName+".zip")
file, err := r.fs.OpenWritable(safePath)
if err != nil {
panic(err)
}
file.Close()
respData := CreateArtifactResponse{ respData := CreateArtifactResponse{
Ok: true, Ok: true,
SignedUploadUrl: r.buildArtifactURL("UploadArtifact", artifactName, runID), SignedUploadUrl: r.buildArtifactURL("UploadArtifact", artifactName, runID),
@@ -292,12 +302,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
safePath := safeResolve(safeRunPath, artifactName) safePath := safeResolve(safeRunPath, artifactName)
safePath = safeResolve(safePath, artifactName+".zip") safePath = safeResolve(safePath, artifactName+".zip")
file, err := func() (WritableFile, error) { file, err := r.fs.OpenAppendable(safePath)
if comp == "appendBlock" {
return r.fs.OpenAppendable(safePath)
}
return r.fs.OpenWritable(safePath)
}()
if err != nil { if err != nil {
panic(err) panic(err)
@@ -317,6 +322,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
file.Close()
ctx.JSON(http.StatusCreated, "appended") ctx.JSON(http.StatusCreated, "appended")
case "blocklist": case "blocklist":
ctx.JSON(http.StatusCreated, "created") ctx.JSON(http.StatusCreated, "created")