Skip to content

Commit a79d834

Browse files
IronboxpluscykKirCute
authored
fix(fs): handle non-existent destination directory in file transfer (OpenListTeam#1898)
* fix(FileTransferTask): skip copying if destination directory does not exist * pass only object not found error --------- Co-authored-by: cyk <[email protected]> Co-authored-by: KirCute <[email protected]>
1 parent f057846 commit a79d834

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/fs/copy_move.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ func (t *FileTransferTask) RunWithNextTaskCallback(f func(nextTask *FileTransfer
192192
existedObjs := make(map[string]bool)
193193
if t.TaskType == merge {
194194
dstObjs, err := op.List(t.Ctx(), t.DstStorage, dstActualPath, model.ListArgs{})
195-
if err != nil {
195+
if err != nil && !errors.Is(err, errs.ObjectNotFound) {
196+
// 目标文件夹不存在的情况不是错误,会在之后新建文件夹
197+
// 这种情况显然不需要统计existedObjs,dstObjs保持为nil,下面这个for将不会执行
196198
return errors.WithMessagef(err, "failed list dst [%s] objs", dstActualPath)
197199
}
198200
for _, obj := range dstObjs {

0 commit comments

Comments
 (0)