🔒 not allowed delete root folder

This commit is contained in:
微凉
2022-01-13 21:23:27 +08:00
parent 65a01251e9
commit b472c2ee18
9 changed files with 27 additions and 19 deletions

View File

@ -1,7 +1,6 @@
package file
import (
"errors"
"github.com/Xhofe/alist/drivers/base"
"github.com/Xhofe/alist/drivers/operate"
"github.com/Xhofe/alist/server/common"
@ -21,7 +20,7 @@ func DeleteFiles(c *gin.Context) {
return
}
if len(req.Names) == 0 {
common.ErrorResp(c, errors.New("empty file names"), 400)
common.ErrorStrResp(c, "Empty file names", 400)
return
}
for i, name := range req.Names {
@ -30,6 +29,10 @@ func DeleteFiles(c *gin.Context) {
common.ErrorResp(c, err, 500)
return
}
if path_ == "/" {
common.ErrorStrResp(c, "Delete root folder is not allowed", 400)
return
}
clearCache := false
if i == len(req.Names)-1 {
clearCache = true