You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
467 B

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