Skip to content

Commit

Permalink
feat: 优化文件上传逻辑,减少临时空间占用
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed Jun 19, 2024
1 parent b6d916d commit 572c3a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/app/api/v1/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ func (b *BaseApi) Size(c *gin.Context) {
}

func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int, overwrite bool) error {
defer func() {
_ = os.RemoveAll(fileDir)
}()

op := files.NewFileOp()
dstDir = strings.TrimSpace(dstDir)
mode, _ := files.GetParentMode(dstDir)
Expand Down Expand Up @@ -629,9 +633,10 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
if err != nil {
return err
}
_ = os.Remove(chunkPath)
}

return files.NewFileOp().DeleteDir(fileDir)
return nil
}

// @Tags File
Expand Down

0 comments on commit 572c3a3

Please sign in to comment.