Skip to content

Commit 07597c7

Browse files
authored
Add support for action artifact serve direct (go-gitea#29120)
Fixes go-gitea#29093
1 parent 702a876 commit 07597c7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

routers/api/actions/artifacts.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ package actions
6363

6464
import (
6565
"crypto/md5"
66+
"errors"
6667
"fmt"
6768
"net/http"
6869
"strconv"
@@ -426,7 +427,19 @@ func (ar artifactRoutes) getDownloadArtifactURL(ctx *ArtifactContext) {
426427

427428
var items []downloadArtifactResponseItem
428429
for _, artifact := range artifacts {
429-
downloadURL := ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
430+
var downloadURL string
431+
if setting.Actions.ArtifactStorage.MinioConfig.ServeDirect {
432+
u, err := ar.fs.URL(artifact.StoragePath, artifact.ArtifactName)
433+
if err != nil && !errors.Is(err, storage.ErrURLNotSupported) {
434+
log.Error("Error getting serve direct url: %v", err)
435+
}
436+
if u != nil {
437+
downloadURL = u.String()
438+
}
439+
}
440+
if downloadURL == "" {
441+
downloadURL = ar.buildArtifactURL(runID, strconv.FormatInt(artifact.ID, 10), "download")
442+
}
430443
item := downloadArtifactResponseItem{
431444
Path: util.PathJoinRel(itemPath, artifact.ArtifactPath),
432445
ItemType: "file",

0 commit comments

Comments
 (0)