Modify: check whether file exist before deleting unfinished uploading
This commit is contained in:
parent
5f7ece6d82
commit
0dddc12609
1 changed files with 6 additions and 3 deletions
|
@ -3,6 +3,7 @@ package filesystem
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
)
|
||||
|
||||
// GenericBeforeUpload 通用上传前处理钩子,包含数据库操作
|
||||
|
@ -33,9 +34,11 @@ func GenericBeforeUpload(ctx context.Context, fs *FileSystem, file FileData) err
|
|||
func GenericAfterUploadCanceled(ctx context.Context, fs *FileSystem, file FileData) error {
|
||||
filePath := ctx.Value("path").(string)
|
||||
// 删除临时文件
|
||||
_, err := fs.Handler.Delete(ctx, []string{filePath})
|
||||
if err != nil {
|
||||
return err
|
||||
if util.Exists(filePath) {
|
||||
_, err := fs.Handler.Delete(ctx, []string{filePath})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 归还用户容量
|
||||
|
|
Loading…
Reference in a new issue