blob: cf359ca400b0830b7d381bbdf4ad21c95a897154 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package rclone_backend
import "github.com/rclone/rclone/fs/accounting"
type ProgressReader struct {
acc *accounting.Account
tr *accounting.Transfer
fn func(progressed int64, percentage float32) error
}
func (pr *ProgressReader) Read(p []byte) (n int, err error) {
n, err = pr.acc.Read(p)
if err != nil {
return
}
snap := pr.tr.Snapshot()
err = pr.fn(snap.Bytes, 100*float32(snap.Bytes)/float32(snap.Size))
return
}
|