"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
Only show transfer stats on commands which transfer stuff - fixes #849
Nick Craig-Wood2cbdb95ce584
diff --git a/cmd/cat/cat.go b/cmd/cat/cat.goindex 5ae6b5928..d650a59cd 100644--- a/cmd/cat/cat.go+++ b/cmd/cat/cat.go@@ -33,7 +33,7 @@ Or like this to output any .txt files in dir or subdirectories.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.Cat(fsrc, os.Stdout)})},diff --git a/cmd/check/check.go b/cmd/check/check.goindex 9c116a09d..fc5db7860 100644--- a/cmd/check/check.go+++ b/cmd/check/check.go@@ -23,7 +23,7 @@ don't match. It doesn't alter the source or destination.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(2, 2, command, args)fsrc, fdst := cmd.NewFsSrcDst(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.Check(fdst, fsrc)})},diff --git a/cmd/cleanup/cleanup.go b/cmd/cleanup/cleanup.goindex 91be86b98..696d9f0e4 100644--- a/cmd/cleanup/cleanup.go+++ b/cmd/cleanup/cleanup.go@@ -20,7 +20,7 @@ versions. Not supported by all remotes.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.CleanUp(fsrc)})},diff --git a/cmd/cmd.go b/cmd/cmd.goindex 098a8383b..3817594a5 100644--- a/cmd/cmd.go+++ b/cmd/cmd.go@@ -225,9 +225,12 @@ func NewFsDst(args []string) fs.Fs {}// Run the function with stats and retries if required-func Run(Retry bool, cmd *cobra.Command, f func() error) {+func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {var err error- stopStats := startStats()+ var stopStats chan struct{}+ if showStats {+ stopStats = startStats()+ }for try := 1; try <= *retries; try++ {err = f()if !Retry || (err == nil && !fs.Stats.Errored()) {@@ -253,11 +256,13 @@ func Run(Retry bool, cmd *cobra.Command, f func() error) {fs.Stats.ResetErrors()}}- close(stopStats)+ if showStats {+ close(stopStats)+ }if err != nil {log.Fatalf("Failed to %s: %v", cmd.Name(), err)}- if !fs.Config.Quiet || fs.Stats.Errored() || *statsInterval > 0 {+ if showStats && (!fs.Config.Quiet || fs.Stats.Errored() || *statsInterval > 0) {fs.Log(nil, "%s", fs.Stats)}if fs.Config.Verbose {diff --git a/cmd/copy/copy.go b/cmd/copy/copy.goindex 80f2b8e11..920b80cff 100644--- a/cmd/copy/copy.go+++ b/cmd/copy/copy.go@@ -56,7 +56,7 @@ the destination directory or not.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(2, 2, command, args)fsrc, fdst := cmd.NewFsSrcDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, true, command, func() error {return fs.CopyDir(fdst, fsrc)})},diff --git a/cmd/copyto/copyto.go b/cmd/copyto/copyto.goindex d0ddbf698..8ea8f2296 100644--- a/cmd/copyto/copyto.go+++ b/cmd/copyto/copyto.go@@ -43,7 +43,7 @@ destination.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(2, 2, command, args)fsrc, srcFileName, fdst, dstFileName := cmd.NewFsSrcDstFiles(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, true, command, func() error {if srcFileName == "" {return fs.CopyDir(fdst, fsrc)}diff --git a/cmd/dedupe/dedupe.go b/cmd/dedupe/dedupe.goindex 357b80f5f..677cab7ac 100644--- a/cmd/dedupe/dedupe.go+++ b/cmd/dedupe/dedupe.go@@ -106,7 +106,7 @@ Orargs = args[1:]}fdst := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.Deduplicate(fdst, dedupeMode)})},diff --git a/cmd/delete/delete.go b/cmd/delete/delete.goindex b46d80f2c..98deaea78 100644--- a/cmd/delete/delete.go+++ b/cmd/delete/delete.go@@ -34,7 +34,7 @@ delete all files bigger than 100MBytes.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.Delete(fsrc)})},diff --git a/cmd/ls/ls.go b/cmd/ls/ls.goindex 4a7a49fb2..a0d2d109e 100644--- a/cmd/ls/ls.go+++ b/cmd/ls/ls.go@@ -18,7 +18,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.List(fsrc, os.Stdout)})},diff --git a/cmd/lsd/lsd.go b/cmd/lsd/lsd.goindex f8bbc3379..5a609c2e6 100644--- a/cmd/lsd/lsd.go+++ b/cmd/lsd/lsd.go@@ -18,7 +18,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.ListDir(fsrc, os.Stdout)})},diff --git a/cmd/lsl/lsl.go b/cmd/lsl/lsl.goindex 988bdb07c..d572510d0 100644--- a/cmd/lsl/lsl.go+++ b/cmd/lsl/lsl.go@@ -18,7 +18,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.ListLong(fsrc, os.Stdout)})},diff --git a/cmd/md5sum/md5sum.go b/cmd/md5sum/md5sum.goindex d03b8163c..e18a2602b 100644--- a/cmd/md5sum/md5sum.go+++ b/cmd/md5sum/md5sum.go@@ -22,7 +22,7 @@ is in the same format as the standard md5sum tool produces.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.Md5sum(fsrc, os.Stdout)})},diff --git a/cmd/memtest/memtest.go b/cmd/memtest/memtest.goindex d25d4b328..c2e7c5012 100644--- a/cmd/memtest/memtest.go+++ b/cmd/memtest/memtest.go@@ -20,7 +20,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {objects, _, err := fs.Count(fsrc)if err != nil {return errdiff --git a/cmd/mkdir/mkdir.go b/cmd/mkdir/mkdir.goindex 82daa8baf..155bd170b 100644--- a/cmd/mkdir/mkdir.go+++ b/cmd/mkdir/mkdir.go@@ -16,7 +16,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fdst := cmd.NewFsDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.Mkdir(fdst, "")})},diff --git a/cmd/move/move.go b/cmd/move/move.goindex e32c048bb..082142d9b 100644--- a/cmd/move/move.go+++ b/cmd/move/move.go@@ -34,7 +34,7 @@ into ` + "`dest:path`" + ` then delete the original (if no errors on copy) inRun: func(command *cobra.Command, args []string) {cmd.CheckArgs(2, 2, command, args)fsrc, fdst := cmd.NewFsSrcDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, true, command, func() error {return fs.MoveDir(fdst, fsrc)})},diff --git a/cmd/moveto/moveto.go b/cmd/moveto/moveto.goindex 0078cb611..3c00964de 100644--- a/cmd/moveto/moveto.go+++ b/cmd/moveto/moveto.go@@ -47,7 +47,7 @@ transfer.cmd.CheckArgs(2, 2, command, args)fsrc, srcFileName, fdst, dstFileName := cmd.NewFsSrcDstFiles(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, true, command, func() error {if srcFileName == "" {return fs.MoveDir(fdst, fsrc)}diff --git a/cmd/purge/purge.go b/cmd/purge/purge.goindex 4f5da1e6d..e4c6a9766 100644--- a/cmd/purge/purge.go+++ b/cmd/purge/purge.go@@ -21,7 +21,7 @@ you want to selectively delete files.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fdst := cmd.NewFsDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.Purge(fdst)})},diff --git a/cmd/rmdir/rmdir.go b/cmd/rmdir/rmdir.goindex 476a5f069..ae38367c4 100644--- a/cmd/rmdir/rmdir.go+++ b/cmd/rmdir/rmdir.go@@ -19,7 +19,7 @@ objects in it, use purge for that.`,Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fdst := cmd.NewFsDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.Rmdir(fdst, "")})},diff --git a/cmd/rmdirs/rmdirs.go b/cmd/rmdirs/rmdirs.goindex fbcb6d7dc..7131e46d0 100644--- a/cmd/rmdirs/rmdirs.go+++ b/cmd/rmdirs/rmdirs.go@@ -24,7 +24,7 @@ empty directories in.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fdst := cmd.NewFsDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, false, command, func() error {return fs.Rmdirs(fdst)})},diff --git a/cmd/sha1sum/sha1sum.go b/cmd/sha1sum/sha1sum.goindex e7696055d..ec181fd8b 100644--- a/cmd/sha1sum/sha1sum.go+++ b/cmd/sha1sum/sha1sum.go@@ -22,7 +22,7 @@ is in the same format as the standard sha1sum tool produces.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {return fs.Sha1sum(fsrc, os.Stdout)})},diff --git a/cmd/size/size.go b/cmd/size/size.goindex f35e0d7db..1d70a3fd0 100644--- a/cmd/size/size.go+++ b/cmd/size/size.go@@ -18,7 +18,7 @@ var commandDefintion = &cobra.Command{Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)- cmd.Run(false, command, func() error {+ cmd.Run(false, false, command, func() error {objects, size, err := fs.Count(fsrc)if err != nil {return errdiff --git a/cmd/sync/sync.go b/cmd/sync/sync.goindex 5e938a658..fb12e502d 100644--- a/cmd/sync/sync.go+++ b/cmd/sync/sync.go@@ -36,7 +36,7 @@ go there.Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(2, 2, command, args)fsrc, fdst := cmd.NewFsSrcDst(args)- cmd.Run(true, command, func() error {+ cmd.Run(true, true, command, func() error {return fs.Sync(fdst, fsrc)})},