mirror of
https://github.com/rclone/rclone.git
synced 2025-01-13 20:38:12 +02:00
fuse: add stats printing and note which files are transferring
This commit is contained in:
parent
be4fd51289
commit
c24da0b886
@ -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() {
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user