mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-23 17:07:57 +08:00
9f55c7c90e
* 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
20 lines
431 B
Go
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
|
|
}
|