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
Fixes go-gitea#29093

(cherry picked from commit 07597c7)
  • Loading branch information
KN4CK3R authored and earl-warren committed Feb 17, 2024
1 parent 7474f62 commit 1f8ad34
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 1f8ad34

Please sign in to comment.