Skip to content

Commit 1647c53

Browse files
committed
set the upload route's server in context so the activity middleware records instead of panicking
1 parent 24f3076 commit 1647c53

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

router/middleware/activity.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/gin-gonic/gin"
55

66
"github.com/pelican-dev/wings/internal/activity"
7+
"github.com/pelican-dev/wings/server"
78
)
89

910
// BumpActivity records an io event against the resolved server. mounted on
@@ -25,11 +26,13 @@ func BumpActivity() gin.HandlerFunc {
2526
return
2627
}
2728

28-
s := ExtractServer(c)
29-
if s == nil {
29+
// soft lookup rather than ExtractServer: the signed upload route has no
30+
// server-injecting middleware, so an absent server is a skip, not a panic.
31+
v, ok := c.Get("server")
32+
if !ok {
3033
return
3134
}
3235

33-
activity.Global().RecordIO(s.Id())
36+
activity.Global().RecordIO(v.(*server.Server).Id())
3437
}
3538
}

router/router_server_files.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ func postServerUploadFiles(c *gin.Context) {
606606
return
607607
}
608608

609+
// this route resolves the server from the upload token rather than a
610+
// server-injecting middleware, so set it on the context for the
611+
// post-handler BumpActivity middleware to record the io against.
612+
c.Set("server", s)
613+
609614
form, err := c.MultipartForm()
610615
if err != nil {
611616
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{

0 commit comments

Comments
 (0)