1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Merge pull request #108 from DanielHeath/mutex-save

Add mutex around page.Save(), fixes #70
This commit is contained in:
Zack 2018-01-27 07:56:39 -05:00 committed by GitHub
commit a0dcc9652f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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