Skip to content

Commit 4590795

Browse files
authored
fixed(fs):fixed overwrite functions (#469)
* fixed(fs):fixed overwrite functions
1 parent 060fd36 commit 4590795

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

server/handles/fsmanage.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ func FsMove(c *gin.Context) {
8888
common.ErrorResp(c, err, 403)
8989
return
9090
}
91+
92+
if !req.Overwrite {
93+
for _, name := range req.Names {
94+
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
95+
common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
96+
return
97+
}
98+
}
99+
}
91100

92101
// Create all tasks immediately without any synchronous validation
93102
// All validation will be done asynchronously in the background
@@ -141,6 +150,15 @@ func FsCopy(c *gin.Context) {
141150
common.ErrorResp(c, err, 403)
142151
return
143152
}
153+
154+
if !req.Overwrite {
155+
for _, name := range req.Names {
156+
if res, _ := fs.Get(c, stdpath.Join(dstDir, name), &fs.GetArgs{NoLog: true}); res != nil {
157+
common.ErrorStrResp(c, fmt.Sprintf("file [%s] exists", name), 403)
158+
return
159+
}
160+
}
161+
}
144162

145163
// Create all tasks immediately without any synchronous validation
146164
// All validation will be done asynchronously in the background

0 commit comments

Comments
 (0)