diff --git a/lib/persistedmap/persistedmap.go b/lib/persistedmap/persistedmap.go index 06b6e406..1daa6e7d 100644 --- a/lib/persistedmap/persistedmap.go +++ b/lib/persistedmap/persistedmap.go @@ -61,11 +61,12 @@ func (p *PersistedMap) flushRoutine() { } func (p *PersistedMap) flush() error { + p.mu.Lock() + if !p.shouldSave { return nil } - p.mu.Lock() defer p.mu.Unlock() file, err := os.Create(p.filePath)