コード例 #1
0
ファイル: puller.go プロジェクト: jjoergensen/syncthing
func (p *puller) queueNeededBlocks() {
	queued := 0
	for _, f := range p.model.NeedFilesRepo(p.repoCfg.ID) {
		lf := p.model.CurrentRepoFile(p.repoCfg.ID, f.Name)
		have, need := scanner.BlockDiff(lf.Blocks, f.Blocks)
		if debug {
			l.Debugf("need:\n  local: %v\n  global: %v\n  haveBlocks: %v\n  needBlocks: %v", lf, f, have, need)
		}
		queued++
		p.bq.put(bqAdd{
			file: f,
			have: have,
			need: need,
		})
	}
	if debug && queued > 0 {
		l.Debugf("%q: queued %d blocks", p.repoCfg.ID, queued)
	}
}
コード例 #2
0
ファイル: puller.go プロジェクト: KayoticSully/syncthing
func (p *puller) queueNeededBlocks(prevVer uint64) (uint64, int) {
	curVer := p.model.LocalVersion(p.repoCfg.ID)
	if curVer == prevVer {
		return curVer, 0
	}

	if debug {
		l.Debugf("%q: checking for more needed blocks", p.repoCfg.ID)
	}

	queued := 0
	for _, f := range p.model.NeedFilesRepo(p.repoCfg.ID) {
		if _, ok := p.openFiles[f.Name]; ok {
			continue
		}
		lf := p.model.CurrentRepoFile(p.repoCfg.ID, f.Name)
		have, need := scanner.BlockDiff(lf.Blocks, f.Blocks)
		if debug {
			l.Debugf("need:\n  local: %v\n  global: %v\n  haveBlocks: %v\n  needBlocks: %v", lf, f, have, need)
		}
		queued++
		p.bq.put(bqAdd{
			file: f,
			have: have,
			need: need,
		})
	}
	if debug && queued > 0 {
		l.Debugf("%q: queued %d items", p.repoCfg.ID, queued)
	}

	if queued > 0 {
		return prevVer, queued
	} else {
		return curVer, 0
	}
}