fix(archive): use another sign for extraction (#7982)
This commit is contained in:
@ -9,35 +9,36 @@ import (
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/internal/sign"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func Down(c *gin.Context) {
|
||||
rawPath := parsePath(c.Param("path"))
|
||||
c.Set("path", rawPath)
|
||||
meta, err := op.GetNearestMeta(rawPath)
|
||||
if err != nil {
|
||||
if !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
c.Set("meta", meta)
|
||||
// verify sign
|
||||
if needSign(meta, rawPath) {
|
||||
s := c.Query("sign")
|
||||
err = sign.Verify(rawPath, strings.TrimSuffix(s, "/"))
|
||||
func Down(verifyFunc func(string, string) error) func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
rawPath := parsePath(c.Param("path"))
|
||||
c.Set("path", rawPath)
|
||||
meta, err := op.GetNearestMeta(rawPath)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 401)
|
||||
c.Abort()
|
||||
return
|
||||
if !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
c.Set("meta", meta)
|
||||
// verify sign
|
||||
if needSign(meta, rawPath) {
|
||||
s := c.Query("sign")
|
||||
err = verifyFunc(rawPath, strings.TrimSuffix(s, "/"))
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 401)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
||||
// TODO: implement
|
||||
|
Reference in New Issue
Block a user