Skip to content

Commit

Permalink
Add support for action artifact serve direct (go-gitea#29120)
Browse files Browse the repository at this point in the history
  • Loading branch information
KN4CK3R authored and silverwind committed Feb 20, 2024
1 parent 377b1d9 commit 116205d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion routers/api/actions/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ package actions

import (
"crypto/md5"
"errors"
"fmt"
"net/http"
"strconv"
Expand Down Expand Up @@ -426,7 +427,19 @@ func (ar artifactRoutes) getDownloadArtifactURL(ctx *ArtifactContext) {

var items []downloadArtifactResponseItem
for _, artifact := range artifacts {
downloadURL := ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
var downloadURL string
if setting.Actions.ArtifactStorage.MinioConfig.ServeDirect {
u, err := ar.fs.URL(artifact.StoragePath, artifact.ArtifactName)
if err != nil && !errors.Is(err, storage.ErrURLNotSupported) {
log.Error("Error getting serve direct url: %v", err)
}
if u != nil {
downloadURL = u.String()
}
}
if downloadURL == "" {
downloadURL = ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
}
item := downloadArtifactResponseItem{
Path: util.PathJoinRel(itemPath, artifact.ArtifactPath),
ItemType: "file",
Expand Down

0 comments on commit 116205d

Please sign in to comment.