diff options
author | Jakob Borg <jakob@nym.se> | 2014-07-02 07:40:27 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-07-02 07:40:27 +0200 |
commit | 0aa067a726cf7cdf46a021d8d55307d7f0bce831 (patch) | |
tree | e1373fce369677051e56531a2e7f46062a617315 | |
parent | 5353659f9fcb840142ba4c8d83f48654d43d4bdc (diff) |
Avoid deadlock during initial scan (fixes #389)
-rw-r--r-- | model/model.go | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/model/model.go b/model/model.go index 01519f267e..79245281b5 100644 --- a/model/model.go +++ b/model/model.go @@ -454,19 +454,6 @@ func (m *Model) ReplaceLocal(repo string, fs []scanner.File) { m.rmut.RUnlock() } -func (m *Model) SeedLocal(repo string, fs []protocol.FileInfo) { - var sfs = make([]scanner.File, len(fs)) - for i := 0; i < len(fs); i++ { - lamport.Default.Tick(fs[i].Version) - sfs[i] = fileFromFileInfo(fs[i]) - sfs[i].Suppressed = false // we might have saved an index with files that were suppressed; the should not be on startup - } - - m.rmut.RLock() - m.repoFiles[repo].Replace(cid.LocalID, sfs) - m.rmut.RUnlock() -} - func (m *Model) CurrentRepoFile(repo string, file string) scanner.File { m.rmut.RLock() f := m.repoFiles[repo].Get(cid.LocalID, file) @@ -736,7 +723,15 @@ func (m *Model) LoadIndexes(dir string) { m.rmut.RLock() for repo := range m.repoCfgs { fs := m.loadIndex(repo, dir) - m.SeedLocal(repo, fs) + + var sfs = make([]scanner.File, len(fs)) + for i := 0; i < len(fs); i++ { + lamport.Default.Tick(fs[i].Version) + sfs[i] = fileFromFileInfo(fs[i]) + sfs[i].Suppressed = false // we might have saved an index with files that were suppressed; the should not be on startup + } + + m.repoFiles[repo].Replace(cid.LocalID, sfs) } m.rmut.RUnlock() } |