diff --git a/fs/accounting/accounting.go b/fs/accounting/accounting.go index 34850b5c5..105c72a20 100644 --- a/fs/accounting/accounting.go +++ b/fs/accounting/accounting.go @@ -280,6 +280,12 @@ func (acc *Account) ServerSideCopyEnd(n int64) { acc.stats.Bytes(n) } +// DryRun accounts for statistics without running the operation +func (acc *Account) DryRun(n int64) { + acc.ServerSideCopyStart() + acc.ServerSideCopyEnd(n) +} + // Account for n bytes from the current file bandwidth limit (if any) func (acc *Account) limitPerFileBandwidth(n int) { acc.values.mu.Lock() diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 8f6415965..39358aaa4 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -368,6 +368,8 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Obj }() newDst = dst if SkipDestructive(ctx, src, "copy") { + in := tr.Account(ctx, nil) + in.DryRun(src.Size()) return newDst, nil } maxTries := ci.LowLevelRetries @@ -559,6 +561,8 @@ func Move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs. }() newDst = dst if SkipDestructive(ctx, src, "move") { + in := tr.Account(ctx, nil) + in.DryRun(src.Size()) return newDst, nil } // See if we have Move available @@ -1929,6 +1933,12 @@ func (l *ListFormat) Format(entry *ListJSONItem) (result string) { // if available) and doing renames in parallel. func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err error) { ci := fs.GetConfig(ctx) + + if SkipDestructive(ctx, srcRemote, "dirMove") { + accounting.Stats(ctx).Renames(1) + return nil + } + // Use DirMove if possible if doDirMove := f.Features().DirMove; doDirMove != nil { err = doDirMove(ctx, f, srcRemote, dstRemote)