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:
parent
d9b8bfc95d
commit
d48d1458a5
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user