Lock while accessing folder configs

This commit is contained in:
Audrius Butkevicius 2014-11-09 19:03:56 +00:00
parent 1aaf34b0ed
commit d16dcb9f19
1 changed files with 8 additions and 1 deletions

View File

@ -592,11 +592,18 @@ nextFile:
}
}()
folderRoots := make(map[string]string)
p.model.fmut.RLock()
for folder, cfg := range p.model.folderCfgs {
folderRoots[folder] = cfg.Path
}
p.model.fmut.RUnlock()
hasher := sha256.New()
for _, block := range state.blocks {
buf = buf[:int(block.Size)]
found := p.model.finder.Iterate(block.Hash, func(folder, file string, index uint32) bool {
path := filepath.Join(p.model.folderCfgs[folder].Path, file)
path := filepath.Join(folderRoots[folder], file)
var fd *os.File