Restore ability for any command to show stats by adding --stats flag
Make default for `mount` command not to show stats - this can be re-enabled by adding a `--stats` parameter.
This commit is contained in:
parent
dd60f088ed
commit
43c530922a
3 changed files with 24 additions and 4 deletions
12
cmd/cmd.go
12
cmd/cmd.go
|
@ -224,10 +224,22 @@ func NewFsDst(args []string) fs.Fs {
|
||||||
return fdst
|
return fdst
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShowStats returns true if the user added a `--stats` flag to the command line.
|
||||||
|
//
|
||||||
|
// This is called by Run to override the default value of the
|
||||||
|
// showStats passed in.
|
||||||
|
func ShowStats() bool {
|
||||||
|
statsIntervalFlag := pflag.Lookup("stats")
|
||||||
|
return statsIntervalFlag != nil && statsIntervalFlag.Changed
|
||||||
|
}
|
||||||
|
|
||||||
// Run the function with stats and retries if required
|
// Run the function with stats and retries if required
|
||||||
func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
||||||
var err error
|
var err error
|
||||||
var stopStats chan struct{}
|
var stopStats chan struct{}
|
||||||
|
if !showStats && ShowStats() {
|
||||||
|
showStats = true
|
||||||
|
}
|
||||||
if showStats {
|
if showStats {
|
||||||
stopStats = StartStats()
|
stopStats = StartStats()
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,11 @@ func Mount(f fs.Fs, mountpoint string) error {
|
||||||
dirPerms = 0777 &^ os.FileMode(umask)
|
dirPerms = 0777 &^ os.FileMode(umask)
|
||||||
filePerms = 0666 &^ os.FileMode(umask)
|
filePerms = 0666 &^ os.FileMode(umask)
|
||||||
|
|
||||||
// Show stats
|
// Show stats if the user has specifically requested them
|
||||||
stopStats := cmd.StartStats()
|
if cmd.ShowStats() {
|
||||||
defer close(stopStats)
|
stopStats := cmd.StartStats()
|
||||||
|
defer close(stopStats)
|
||||||
|
}
|
||||||
|
|
||||||
// Mount it
|
// Mount it
|
||||||
errChan, err := mount(f, mountpoint)
|
errChan, err := mount(f, mountpoint)
|
||||||
|
|
|
@ -390,12 +390,18 @@ modification times in the same way as rclone.
|
||||||
|
|
||||||
### --stats=TIME ###
|
### --stats=TIME ###
|
||||||
|
|
||||||
Rclone will print stats at regular intervals to show its progress.
|
Commands which transfer data (`sync`, `copy`, `copyto`, `move`,
|
||||||
|
`moveto`) will print data transfer stats at regular intervals to show
|
||||||
|
their progress.
|
||||||
|
|
||||||
This sets the interval.
|
This sets the interval.
|
||||||
|
|
||||||
The default is `1m`. Use 0 to disable.
|
The default is `1m`. Use 0 to disable.
|
||||||
|
|
||||||
|
If you set the stats interval then all command can show stats. This
|
||||||
|
can be useful when running other commands, `check` or `mount` for
|
||||||
|
example.
|
||||||
|
|
||||||
### --stats-unit=bits|bytes ###
|
### --stats-unit=bits|bytes ###
|
||||||
|
|
||||||
By default data transfer rates will be printed in bytes/second.
|
By default data transfer rates will be printed in bytes/second.
|
||||||
|
|
Loading…
Add table
Reference in a new issue