Skip to content

Commit 34c2b7d

Browse files
committed
fix(upload): 修复FsPreup函数中的文件存在检查逻辑
1 parent 7ccabf4 commit 34c2b7d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

server/handles/fsup.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,10 @@ func FsPreup(c *gin.Context) {
250250

251251
storage := c.Request.Context().Value(conf.StorageKey).(driver.Driver)
252252
path := c.Request.Context().Value(conf.PathKey).(string)
253-
if !req.Overwrite {
254-
if res, _ := fs.Get(c.Request.Context(), path, &fs.GetArgs{NoLog: true}); res != nil {
255-
common.ErrorStrResp(c, "file exists", 403)
256-
return
257-
}
253+
fullPath := utils.FixAndCleanPath(stdpath.Join(path, req.Name))
254+
if res, _ := fs.Get(c.Request.Context(), fullPath, &fs.GetArgs{NoLog: true}); res != nil && !req.Overwrite {
255+
common.ErrorStrResp(c, "file exists", 403)
256+
return
258257
}
259258

260259
res, err := fs.Preup(c.Request.Context(), storage, path, req)

0 commit comments

Comments
 (0)