feat(fs): display the existing filename in error message (#7877)

pull/7807/head^2
Jealous 2025-01-27 20:09:17 +08:00 committed by GitHub
parent 5c5d8378e5
commit 0d4c63e9ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -90,7 +90,7 @@ func FsMove(c *gin.Context) {
if !req.Overwrite { if !req.Overwrite {
for _, name := range req.Names { for _, name := range req.Names {
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil { if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
common.ErrorStrResp(c, "file exists", 403) common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
return return
} }
} }
@ -133,7 +133,7 @@ func FsCopy(c *gin.Context) {
if !req.Overwrite { if !req.Overwrite {
for _, name := range req.Names { for _, name := range req.Names {
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil { if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
common.ErrorStrResp(c, "file exists", 403) common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
return return
} }
} }
@ -180,7 +180,7 @@ func FsRename(c *gin.Context) {
dstPath := stdpath.Join(stdpath.Dir(reqPath), req.Name) dstPath := stdpath.Join(stdpath.Dir(reqPath), req.Name)
if dstPath != reqPath { if dstPath != reqPath {
if res, _ := fs.Get(c, dstPath, &fs.GetArgs{NoLog: true}); res != nil { if res, _ := fs.Get(c, dstPath, &fs.GetArgs{NoLog: true}); res != nil {
common.ErrorStrResp(c, "file exists", 403) common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", req.Name), 403)
return return
} }
} }