"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fs/accounting: fix moving average speed for file stats
Nick Craig-Woodde6ec8056fc1
diff --git a/fs/accounting/accounting.go b/fs/accounting/accounting.goindex a3746f5e9..398588d72 100644--- a/fs/accounting/accounting.go+++ b/fs/accounting/accounting.go@@ -129,6 +129,7 @@ func (acc *Account) UpdateReader(in io.ReadCloser) {// averageLoop calculates averages for the stats in the backgroundfunc (acc *Account) averageLoop() {tick := time.NewTicker(time.Second)+ var period float64defer tick.Stop()for {select {@@ -137,7 +138,11 @@ func (acc *Account) averageLoop() {// Add average of last second.elapsed := now.Sub(acc.lpTime).Seconds()avg := float64(acc.lpBytes) / elapsed- acc.avg = (avg + (averagePeriod-1)*acc.avg) / averagePeriod+ // Soft start the moving average+ if period < averagePeriod {+ period+++ }+ acc.avg = (avg + (period-1)*acc.avg) / periodacc.lpBytes = 0acc.lpTime = now// Unlock stats