✨ ali path and link
This commit is contained in:
@ -27,7 +27,7 @@ func ParsePath(rawPath string) (*model.Account,string,drivers.Driver,error) {
|
||||
break
|
||||
default:
|
||||
paths := strings.Split(rawPath,"/")
|
||||
path = strings.Join(paths[2:],"/")
|
||||
path = "/" + strings.Join(paths[2:],"/")
|
||||
name = paths[1]
|
||||
}
|
||||
account,ok := model.GetAccount(name)
|
||||
|
@ -1,9 +1,19 @@
|
||||
package server
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
import (
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func Down(ctx *fiber.Ctx) error {
|
||||
rawPath := ctx.Params("*")
|
||||
rawPath, err:= url.QueryUnescape(ctx.Params("*"))
|
||||
if err != nil {
|
||||
return ErrorResp(ctx,err,500)
|
||||
}
|
||||
rawPath = utils.ParsePath(rawPath)
|
||||
log.Debugf("down: %s",rawPath)
|
||||
account, path, driver, err := ParsePath(rawPath)
|
||||
if err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
|
@ -1,9 +1,11 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"strings"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type PathReq struct {
|
||||
@ -16,8 +18,14 @@ func Path(ctx *fiber.Ctx) error {
|
||||
if err := ctx.BodyParser(&req); err != nil {
|
||||
return ErrorResp(ctx, err, 400)
|
||||
}
|
||||
if !strings.HasPrefix(req.Path, "/") {
|
||||
req.Path = "/"+req.Path
|
||||
req.Path = utils.ParsePath(req.Path)
|
||||
log.Debugf("path: %s",req.Path)
|
||||
meta, err := model.GetMetaByPath(req.Path)
|
||||
if err == nil {
|
||||
if meta.Password != "" && meta.Password!= req.Password {
|
||||
return ErrorResp(ctx,fmt.Errorf("wrong password"),401)
|
||||
}
|
||||
// TODO hide or ignore?
|
||||
}
|
||||
if model.AccountsCount() > 1 && req.Path == "/" {
|
||||
return ctx.JSON(Resp{
|
||||
|
Reference in New Issue
Block a user