mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Add mutex around Save, fixes #70
This commit is contained in:
parent
526688c7e3
commit
b18f40e336
5
page.go
5
page.go
@ -8,6 +8,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/schollz/versionedtext"
|
"github.com/schollz/versionedtext"
|
||||||
@ -107,7 +108,11 @@ func (p *Page) Render() {
|
|||||||
p.RenderedPage = MarkdownToHtml(p.Text.GetCurrent())
|
p.RenderedPage = MarkdownToHtml(p.Text.GetCurrent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var saveMut = sync.Mutex{}
|
||||||
|
|
||||||
func (p *Page) Save() error {
|
func (p *Page) Save() error {
|
||||||
|
saveMut.Lock()
|
||||||
|
defer saveMut.Unlock()
|
||||||
bJSON, err := json.MarshalIndent(p, "", " ")
|
bJSON, err := json.MarshalIndent(p, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user