Skip to content

Commit 32b6bb7

Browse files
fix: artifact v4 upload above 8MB (#2402)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 38e43bd commit 32b6bb7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/artifacts/arifacts_v4.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ func (r *artifactV4Routes) createArtifact(ctx *ArtifactContext) {
271271

272272
artifactName := req.Name
273273

274+
safeRunPath := safeResolve(r.baseDir, fmt.Sprint(runID))
275+
safePath := safeResolve(safeRunPath, artifactName)
276+
safePath = safeResolve(safePath, artifactName+".zip")
277+
file, err := r.fs.OpenWritable(safePath)
278+
279+
if err != nil {
280+
panic(err)
281+
}
282+
file.Close()
283+
274284
respData := CreateArtifactResponse{
275285
Ok: true,
276286
SignedUploadUrl: r.buildArtifactURL("UploadArtifact", artifactName, runID),
@@ -292,12 +302,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
292302
safePath := safeResolve(safeRunPath, artifactName)
293303
safePath = safeResolve(safePath, artifactName+".zip")
294304

295-
file, err := func() (WritableFile, error) {
296-
if comp == "appendBlock" {
297-
return r.fs.OpenAppendable(safePath)
298-
}
299-
return r.fs.OpenWritable(safePath)
300-
}()
305+
file, err := r.fs.OpenAppendable(safePath)
301306

302307
if err != nil {
303308
panic(err)
@@ -317,6 +322,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
317322
if err != nil {
318323
panic(err)
319324
}
325+
file.Close()
320326
ctx.JSON(http.StatusCreated, "appended")
321327
case "blocklist":
322328
ctx.JSON(http.StatusCreated, "created")

0 commit comments

Comments
 (0)