mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
fix(model): create fileset under lock (#9840)
I came accross this in another context and didn't investigate fully, but literally ten lines above this code, in another method, we say that filesets _must_ be created under the lock. It's either one or the other and I'm taking the safer route here. --------- Co-authored-by: Simon Frei <freisim93@gmail.com>
This commit is contained in:
parent
f08a0ed01c
commit
43ebac4242
@ -565,16 +565,17 @@ func (m *model) restartFolder(from, to config.FolderConfiguration, cacheIgnoredF
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) newFolder(cfg config.FolderConfiguration, cacheIgnoredFiles bool) error {
|
func (m *model) newFolder(cfg config.FolderConfiguration, cacheIgnoredFiles bool) error {
|
||||||
// Creating the fileset can take a long time (metadata calculation) so
|
m.mut.Lock()
|
||||||
// we do it outside of the lock.
|
defer m.mut.Unlock()
|
||||||
|
|
||||||
|
// Creating the fileset can take a long time (metadata calculation), but
|
||||||
|
// nevertheless should happen inside the lock (same as when restarting
|
||||||
|
// a folder).
|
||||||
fset, err := db.NewFileSet(cfg.ID, m.db)
|
fset, err := db.NewFileSet(cfg.ID, m.db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("adding %v: %w", cfg.Description(), err)
|
return fmt.Errorf("adding %v: %w", cfg.Description(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.mut.Lock()
|
|
||||||
defer m.mut.Unlock()
|
|
||||||
|
|
||||||
m.addAndStartFolderLocked(cfg, fset, cacheIgnoredFiles)
|
m.addAndStartFolderLocked(cfg, fset, cacheIgnoredFiles)
|
||||||
|
|
||||||
// Cluster configs might be received and processed before reaching this
|
// Cluster configs might be received and processed before reaching this
|
||||||
|
Loading…
Reference in New Issue
Block a user