diff --git a/lib/persistedmap/persistedmap.go b/lib/persistedmap/persistedmap.go index 1daa6e7d..5bba2fce 100644 --- a/lib/persistedmap/persistedmap.go +++ b/lib/persistedmap/persistedmap.go @@ -62,13 +62,12 @@ func (p *PersistedMap) flushRoutine() { func (p *PersistedMap) flush() error { p.mu.Lock() + defer p.mu.Unlock() if !p.shouldSave { return nil } - defer p.mu.Unlock() - file, err := os.Create(p.filePath) if err != nil { return fmt.Errorf("failed to create file: %w", err)