"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fs: Accumulate stats when using --dry-run
Ingo Weiss1d40bc1901a7
diff --git a/fs/accounting/accounting.go b/fs/accounting/accounting.goindex 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.goindex 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 = dstif 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 = dstif 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 possibleif doDirMove := f.Features().DirMove; doDirMove != nil {err = doDirMove(ctx, f, srcRemote, dstRemote)