From d48d1458a5dbe37db9c7bec8dc688e1b3291b4f7 Mon Sep 17 00:00:00 2001 From: Daniel Heath Date: Sat, 28 Apr 2018 19:32:48 +1000 Subject: [PATCH] Make save mutex per-site --- server/handlers.go | 3 +++ server/page.go | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) 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