Feat: disable overwrite for non-updating put request, only works under local,slave,OneDrive,OSS policy. (#764)

This commit is contained in:
HFO4
2021-03-01 13:03:49 +08:00
parent c949d47161
commit 5e226efea1
16 changed files with 67 additions and 15 deletions

View File

@@ -10,6 +10,7 @@ import (
model "github.com/cloudreve/Cloudreve/v3/models"
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem"
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx"
"github.com/cloudreve/Cloudreve/v3/pkg/util"
)
@@ -102,7 +103,8 @@ func (job *TransferTask) Do() {
dst = path.Join(job.TaskProps.Dst, strings.TrimPrefix(src, trim))
}
err = fs.UploadFromPath(context.Background(), file, dst)
ctx := context.WithValue(context.Background(), fsctx.DisableOverwrite, true)
err = fs.UploadFromPath(ctx, file, dst)
if err != nil {
job.SetErrorMsg("文件转存失败", err)
}