fixed(fs):fixed overwrite functions (#469)

* fixed(fs):fixed overwrite functions
This commit is contained in:
Suyunjing
2025-06-29 12:17:23 +08:00
committed by GitHub
parent 060fd36883
commit 4590795cba

View File

@ -89,6 +89,15 @@ func FsMove(c *gin.Context) {
return
}
if !req.Overwrite {
for _, name := range req.Names {
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
return
}
}
}
// Create all tasks immediately without any synchronous validation
// All validation will be done asynchronously in the background
var addedTasks []task.TaskExtensionInfo
@ -142,6 +151,15 @@ func FsCopy(c *gin.Context) {
return
}
if !req.Overwrite {
for _, name := range req.Names {
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
return
}
}
}
// Create all tasks immediately without any synchronous validation
// All validation will be done asynchronously in the background
var addedTasks []task.TaskExtensionInfo