use mutex to guard sqlite writes

This commit is contained in:
2025-05-13 00:52:16 +01:00
parent a2a2d008dd
commit 28a33f869b

View File

@@ -703,10 +703,12 @@ func updateSummary(ctx context.Context, state *state, opts updateSummaryOptions)
summary := result.Text()
state.dbMutex.Lock()
_, err = state.db.ExecContext(ctx, "INSERT OR REPLACE INTO summaries (location, summary) VALUES (?, ?)", locKey, summary)
if err != nil {
slog.Warn("unable to cache generated weather summary to db", "location", locKey, "error", err)
}
state.dbMutex.Unlock()
state.summaries.Store(locKey, summary)