mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 17:14:44 +01:00
rc: fix setting bwlimit to unlimited
This commit is contained in:
parent
764440068e
commit
9f04ce282e
@ -115,6 +115,19 @@ func limitBandwidth(n int) {
|
|||||||
tokenBucketMu.Unlock()
|
tokenBucketMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetBwLimit sets the current bandwidth limit
|
||||||
|
func SetBwLimit(bandwidth fs.SizeSuffix) {
|
||||||
|
tokenBucketMu.Lock()
|
||||||
|
defer tokenBucketMu.Unlock()
|
||||||
|
if bandwidth > 0 {
|
||||||
|
tokenBucket = newTokenBucket(bandwidth)
|
||||||
|
fs.Logf(nil, "Bandwidth limit set to %v", bandwidth)
|
||||||
|
} else {
|
||||||
|
tokenBucket = nil
|
||||||
|
fs.Logf(nil, "Bandwidth limit reset to unlimited")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remote control for the token bucket
|
// Remote control for the token bucket
|
||||||
func init() {
|
func init() {
|
||||||
rc.Add(rc.Call{
|
rc.Add(rc.Call{
|
||||||
@ -137,10 +150,7 @@ func init() {
|
|||||||
return out, errors.New("need exactly 1 bandwidth setting")
|
return out, errors.New("need exactly 1 bandwidth setting")
|
||||||
}
|
}
|
||||||
bw := bws[0]
|
bw := bws[0]
|
||||||
tokenBucketMu.Lock()
|
SetBwLimit(bw.Bandwidth)
|
||||||
tokenBucket = newTokenBucket(bw.Bandwidth)
|
|
||||||
tokenBucketMu.Unlock()
|
|
||||||
fs.Logf(nil, "Bandwidth limit set to %v", bw.Bandwidth)
|
|
||||||
return rc.Params{"rate": bw.Bandwidth.String()}, nil
|
return rc.Params{"rate": bw.Bandwidth.String()}, nil
|
||||||
},
|
},
|
||||||
Title: "Set the bandwidth limit.",
|
Title: "Set the bandwidth limit.",
|
||||||
|
Loading…
Reference in New Issue
Block a user