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

Make save mutex per-site

This commit is contained in:
Daniel Heath 2018-04-28 19:32:48 +10:00
parent d9b8bfc95d
commit d48d1458a5
2 changed files with 5 additions and 5 deletions

View File

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

View File

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