🎇 finish move api

This commit is contained in:
微凉
2022-01-20 19:58:25 +08:00
parent de638c7c36
commit 9516ac6718
4 changed files with 12 additions and 3 deletions

View File

@ -16,9 +16,9 @@ func Folder(c *gin.Context) {
common.ErrorResp(c, err, 400)
return
}
var files []model.File
var files = make([]model.File, 0)
var err error
if model.AccountsCount() > 1 && req.Path == "/" {
if model.AccountsCount() > 1 && (req.Path == "/" || req.Path == "") {
files, err = model.GetAccountFiles()
if err != nil {
common.ErrorResp(c, err, 500)

View File

@ -3,6 +3,7 @@ package file
import (
"github.com/Xhofe/alist/drivers/base"
"github.com/Xhofe/alist/drivers/operate"
"github.com/Xhofe/alist/model"
"github.com/Xhofe/alist/server/common"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
@ -24,6 +25,10 @@ func Move(c *gin.Context) {
common.ErrorStrResp(c, "Empty file names", 400)
return
}
if model.AccountsCount() > 1 && (req.SrcDir == "/" || req.DstDir == "/") {
common.ErrorStrResp(c, "Can't operate root folder", 400)
return
}
srcAccount, srcPath, srcDriver, err := common.ParsePath(utils.Join(req.SrcDir, req.Names[0]))
if err != nil {
common.ErrorResp(c, err, 500)

View File

@ -77,7 +77,7 @@ func Path(c *gin.Context) {
if meta != nil && meta.Upload {
upload = true
}
if model.AccountsCount() > 1 && req.Path == "/" {
if model.AccountsCount() > 1 && (req.Path == "/" || req.Path == "") {
files, err := model.GetAccountFiles()
if err != nil {
common.ErrorResp(c, err, 500)