diff --git a/cmd/cmd.go b/cmd/cmd.go index 3817594a5..23ee116f2 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -229,7 +229,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) { var err error var stopStats chan struct{} if showStats { - stopStats = startStats() + stopStats = StartStats() } for try := 1; try <= *retries; try++ { err = f() @@ -286,10 +286,10 @@ func CheckArgs(MinArgs, MaxArgs int, cmd *cobra.Command, args []string) { } } -// startStats prints the stats every statsInterval +// StartStats prints the stats every statsInterval // // It returns a channel which should be closed to stop the stats. -func startStats() chan struct{} { +func StartStats() chan struct{} { stopStats := make(chan struct{}) if *statsInterval > 0 { go func() { diff --git a/cmd/mount/mount.go b/cmd/mount/mount.go index ed66cbd29..bd118ded1 100644 --- a/cmd/mount/mount.go +++ b/cmd/mount/mount.go @@ -147,6 +147,10 @@ func Mount(f fs.Fs, mountpoint string) error { dirPerms = 0777 &^ os.FileMode(umask) filePerms = 0666 &^ os.FileMode(umask) + // Show stats + stopStats := cmd.StartStats() + defer close(stopStats) + // Mount it errChan, err := mount(f, mountpoint) if err != nil { diff --git a/cmd/mount/read.go b/cmd/mount/read.go index f4c8d9640..091d33acc 100644 --- a/cmd/mount/read.go +++ b/cmd/mount/read.go @@ -31,6 +31,7 @@ func newReadFileHandle(o fs.Object) (*ReadFileHandle, error) { o: o, r: fs.NewAccount(r, o), // account and buffer the transfer } + fs.Stats.Transferring(fh.o.Remote()) return fh, nil } @@ -123,6 +124,7 @@ func (fh *ReadFileHandle) close() error { return errClosedFileHandle } fh.closed = true + fs.Stats.DoneTransferring(fh.o.Remote(), true) return fh.r.Close() } diff --git a/cmd/mount/write.go b/cmd/mount/write.go index 7d06f5553..8e1da2b92 100644 --- a/cmd/mount/write.go +++ b/cmd/mount/write.go @@ -45,6 +45,7 @@ func newWriteFileHandle(d *Dir, f *File, src fs.ObjectInfo) (*WriteFileHandle, e fh.result <- err }() fh.file.addWriters(1) + fs.Stats.Transferring(fh.remote) return fh, nil } @@ -82,6 +83,7 @@ func (fh *WriteFileHandle) close() error { return errClosedFileHandle } fh.closed = true + fs.Stats.DoneTransferring(fh.remote, true) fh.file.addWriters(-1) writeCloseErr := fh.pipeWriter.Close() err := <-fh.result