mirror of
https://github.com/rclone/rclone
synced 2024-11-23 00:06:55 +01:00
Only show transfer stats on commands which transfer stuff - fixes #849
This commit is contained in:
parent
716ce49ce9
commit
2cbdb95ce5
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
13
cmd/cmd.go
13
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 {
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ Or
|
||||
args = args[1:]
|
||||
}
|
||||
fdst := cmd.NewFsSrc(args)
|
||||
cmd.Run(false, command, func() error {
|
||||
cmd.Run(false, false, command, func() error {
|
||||
return fs.Deduplicate(fdst, dedupeMode)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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 err
|
||||
|
@ -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, "")
|
||||
})
|
||||
},
|
||||
|
@ -34,7 +34,7 @@ into ` + "`dest:path`" + ` then delete the original (if no errors on copy) in
|
||||
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.MoveDir(fdst, fsrc)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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, "")
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
@ -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 err
|
||||
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user