From 03f9910fac227a99f585422fd82dc9c779250d6e Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Wed, 26 Jun 2024 19:26:16 -0700 Subject: [PATCH] Clean up. --- lib/persistedmap/persistedmap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)