From 0badf719e0c3b9123d7b6be7cf7471d170737d5a Mon Sep 17 00:00:00 2001 From: Daniel Heath Date: Sat, 27 Jan 2018 20:57:21 +1100 Subject: [PATCH] Add mutex around Save, fixes #70 --- page.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/page.go b/page.go index 849d97b..df44845 100755 --- a/page.go +++ b/page.go @@ -8,6 +8,7 @@ import ( "regexp" "sort" "strings" + "sync" "time" "github.com/schollz/versionedtext" @@ -107,7 +108,11 @@ func (p *Page) Render() { p.RenderedPage = MarkdownToHtml(p.Text.GetCurrent()) } +var saveMut = sync.Mutex{} + func (p *Page) Save() error { + saveMut.Lock() + defer saveMut.Unlock() bJSON, err := json.MarshalIndent(p, "", " ") if err != nil { return err