seaweedfs/weed/storage/backend/rclone_backend/rclone_progress.go
Damiano Albani 9f55c7c90e
Rclone storage backend (#4402)
* Add Rclone storage backend

* Support templating the name of files stored via Rclone

* Enable Rclone accounting

* Remove redundant type conversion

* Provide progress information for Rclone download/upload operations

* Log error when Rclone can't instantiate filesystem

* Remove filename templating functionality for Rclone storage

To (maybe) be later reintroduced as a generic functionality for all
storage backends.

* Remove S3 specific check

* Move Rclone config initialisation to init() method
2023-04-18 14:12:12 -07:00

20 lines
431 B
Go

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
}