mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Pull files in random-ish order again
This commit is contained in:
parent
5a07f9ddee
commit
f6c9642d72
@ -7,6 +7,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -641,10 +642,17 @@ func (p *puller) queueNeededBlocks(prevVer uint64) (uint64, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queued := 0
|
queued := 0
|
||||||
|
files := make([]protocol.FileInfo, 0, indexBatchSize)
|
||||||
for _, f := range p.model.NeedFilesRepo(p.repoCfg.ID) {
|
for _, f := range p.model.NeedFilesRepo(p.repoCfg.ID) {
|
||||||
if _, ok := p.openFiles[f.Name]; ok {
|
if _, ok := p.openFiles[f.Name]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
files = append(files, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
perm := rand.Perm(len(files))
|
||||||
|
for _, idx := range perm {
|
||||||
|
f := files[idx]
|
||||||
lf := p.model.CurrentRepoFile(p.repoCfg.ID, f.Name)
|
lf := p.model.CurrentRepoFile(p.repoCfg.ID, f.Name)
|
||||||
have, need := scanner.BlockDiff(lf.Blocks, f.Blocks)
|
have, need := scanner.BlockDiff(lf.Blocks, f.Blocks)
|
||||||
if debug {
|
if debug {
|
||||||
@ -657,6 +665,7 @@ func (p *puller) queueNeededBlocks(prevVer uint64) (uint64, int) {
|
|||||||
need: need,
|
need: need,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if debug && queued > 0 {
|
if debug && queued > 0 {
|
||||||
l.Debugf("%q: queued %d items", p.repoCfg.ID, queued)
|
l.Debugf("%q: queued %d items", p.repoCfg.ID, queued)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user