mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-04 01:39:20 +08:00
feat: 优化文件上传逻辑,减少临时空间占用 (#5508)
Refs https://github.com/1Panel-dev/1Panel/issues/5184
This commit is contained in:
parent
1577581257
commit
003c87bf00
@ -593,6 +593,10 @@ func (b *BaseApi) Size(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int, overwrite bool) error {
|
func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int, overwrite bool) error {
|
||||||
|
defer func() {
|
||||||
|
_ = os.RemoveAll(fileDir)
|
||||||
|
}()
|
||||||
|
|
||||||
op := files.NewFileOp()
|
op := files.NewFileOp()
|
||||||
dstDir = strings.TrimSpace(dstDir)
|
dstDir = strings.TrimSpace(dstDir)
|
||||||
mode, _ := files.GetParentMode(dstDir)
|
mode, _ := files.GetParentMode(dstDir)
|
||||||
@ -629,9 +633,10 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
_ = os.Remove(chunkPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.NewFileOp().DeleteDir(fileDir)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Tags File
|
// @Tags File
|
||||||
|
Loading…
Reference in New Issue
Block a user