mirror of
https://github.com/rclone/rclone.git
synced 2025-08-17 17:11:37 +02:00
move: if --check-first and --order-by are set then delete with perfect ordering
If using rclone move and --check-first and --order-by then rclone uses the transfer routine to delete files to ensure perfect ordering. This will cause the transfer stats to have a larger than expected number of items in it so we don't enable this by default. Fixes #6033
This commit is contained in:
@ -377,6 +377,14 @@ func (s *syncCopyMove) pairChecker(in *pipe, out *pipe, fraction int, wg *sync.W
|
||||
fs.Logf(src, "Not removing source file as it is the same file as the destination")
|
||||
} else if s.ci.IgnoreExisting {
|
||||
fs.Debugf(src, "Not removing source file as destination file exists and --ignore-existing is set")
|
||||
} else if s.checkFirst && s.ci.OrderBy != "" {
|
||||
// If we want perfect ordering then use the transfers to delete the file
|
||||
//
|
||||
// We send src == dst, to say we want the src deleted
|
||||
ok = out.Put(s.ctx, fs.ObjectPair{Src: src, Dst: src})
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
s.processError(operations.DeleteFile(s.ctx, src))
|
||||
}
|
||||
@ -417,10 +425,16 @@ func (s *syncCopyMove) pairCopyOrMove(ctx context.Context, in *pipe, fdst fs.Fs,
|
||||
return
|
||||
}
|
||||
src := pair.Src
|
||||
dst := pair.Dst
|
||||
if s.DoMove {
|
||||
_, err = operations.Move(ctx, fdst, pair.Dst, src.Remote(), src)
|
||||
if src != dst {
|
||||
_, err = operations.Move(ctx, fdst, dst, src.Remote(), src)
|
||||
} else {
|
||||
// src == dst signals delete the src
|
||||
err = operations.DeleteFile(ctx, src)
|
||||
}
|
||||
} else {
|
||||
_, err = operations.Copy(ctx, fdst, pair.Dst, src.Remote(), src)
|
||||
_, err = operations.Copy(ctx, fdst, dst, src.Remote(), src)
|
||||
}
|
||||
s.processError(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user