summaryrefslogtreecommitdiffstats
path: root/routers/api/actions/artifacts.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/actions/artifacts.go')
-rw-r--r--routers/api/actions/artifacts.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go
index 5411237103..5bfcc9dfcd 100644
--- a/routers/api/actions/artifacts.go
+++ b/routers/api/actions/artifacts.go
@@ -63,7 +63,6 @@ package actions
import (
"crypto/md5"
- "errors"
"fmt"
"net/http"
"strconv"
@@ -423,15 +422,15 @@ func (ar artifactRoutes) downloadArtifact(ctx *ArtifactContext) {
}
artifactID := ctx.ParamsInt64("artifact_id")
- artifact, err := actions.GetArtifactByID(ctx, artifactID)
- if errors.Is(err, util.ErrNotExist) {
- log.Error("Error getting artifact: %v", err)
- ctx.Error(http.StatusNotFound, err.Error())
- return
- } else if err != nil {
+ artifact, exist, err := db.GetByID[actions.ActionArtifact](ctx, artifactID)
+ if err != nil {
log.Error("Error getting artifact: %v", err)
ctx.Error(http.StatusInternalServerError, err.Error())
return
+ } else if !exist {
+ log.Error("artifact with ID %d does not exist", artifactID)
+ ctx.Error(http.StatusNotFound, fmt.Sprintf("artifact with ID %d does not exist", artifactID))
+ return
}
if artifact.RunID != runID {
log.Error("Error dismatch runID and artifactID, task: %v, artifact: %v", runID, artifactID)