mirror of
https://github.com/rclone/rclone.git
synced 2025-04-19 18:31:10 +08:00
Merge 0625231cb29ed4a293f99913e2df4fab46ff0322 into 4d38424e6cbb32d07c74d3b4d760af7afb35742d
This commit is contained in:
commit
0c42d096da
@ -363,6 +363,32 @@ func (dls *Downloaders) _ensureDownloader(r ranges.Range) (err error) {
|
||||
if r.Size == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shrink existing downloaders to prevent doubling up of ReadAhead in case of multiple file threads / accesses
|
||||
if dls.opt.ReadAhead > 0 {
|
||||
for _, dl = range dls.dls {
|
||||
if dl._closed {
|
||||
continue
|
||||
}
|
||||
|
||||
if dl.maxOffset-dl.start <= window {
|
||||
continue
|
||||
}
|
||||
|
||||
// Adjust this range to shrink without ReadAhead value
|
||||
dl.mu.Lock()
|
||||
dl.maxOffset -= int64(dls.opt.ReadAhead)
|
||||
if dl.maxOffset < dl.start {
|
||||
dl.maxOffset = dl.start
|
||||
}
|
||||
dl.mu.Unlock()
|
||||
|
||||
select {
|
||||
case dl.kick <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
// Downloader not found so start a new one
|
||||
_, err = dls._newDownloader(r)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user