diff --git a/server/handlers.go b/server/handlers.go index 2c986a4..4b83b30 100755 --- a/server/handlers.go +++ b/server/handlers.go @@ -12,6 +12,7 @@ import ( "path" "strconv" "strings" + "sync" "time" secretRequired "github.com/danielheath/gin-teeny-security" @@ -39,6 +40,7 @@ type Site struct { MaxUploadSize uint Logger *lumber.ConsoleLogger + saveMut sync.Mutex sitemapUpToDate bool // TODO this makes everything use a pointer } @@ -95,6 +97,7 @@ func Serve( fileuploads, maxUploadSize, logger, + sync.Mutex{}, false, }.Router() diff --git a/server/page.go b/server/page.go index b80d308..94719b5 100755 --- a/server/page.go +++ b/server/page.go @@ -9,7 +9,6 @@ import ( "regexp" "sort" "strings" - "sync" "time" "github.com/schollz/versionedtext" @@ -164,11 +163,9 @@ func (p *Page) Render() { p.RenderedPage = MarkdownToHtml(p.Text.GetCurrent()) } -var saveMut = sync.Mutex{} - func (p *Page) Save() error { - saveMut.Lock() - defer saveMut.Unlock() + p.Site.saveMut.Lock() + defer p.Site.saveMut.Unlock() bJSON, err := json.MarshalIndent(p, "", " ") if err != nil { return err