Skip to content

Commit

Permalink
fix: artifact v4 upload above 8MB (#2402)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
ChristopherHX and mergify[bot] authored Sep 7, 2024
1 parent 38e43bd commit 32b6bb7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/artifacts/arifacts_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ func (r *artifactV4Routes) createArtifact(ctx *ArtifactContext) {

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{
Ok: true,
SignedUploadUrl: r.buildArtifactURL("UploadArtifact", artifactName, runID),
Expand All @@ -292,12 +302,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
safePath := safeResolve(safeRunPath, artifactName)
safePath = safeResolve(safePath, artifactName+".zip")

file, err := func() (WritableFile, error) {
if comp == "appendBlock" {
return r.fs.OpenAppendable(safePath)
}
return r.fs.OpenWritable(safePath)
}()
file, err := r.fs.OpenAppendable(safePath)

if err != nil {
panic(err)
Expand All @@ -317,6 +322,7 @@ func (r *artifactV4Routes) uploadArtifact(ctx *ArtifactContext) {
if err != nil {
panic(err)
}
file.Close()
ctx.JSON(http.StatusCreated, "appended")
case "blocklist":
ctx.JSON(http.StatusCreated, "created")
Expand Down

0 comments on commit 32b6bb7

Please sign in to comment.