postCreationMutex

This commit is contained in:
Jan-Lukas Else 2021-05-29 22:26:53 +02:00
parent 29dba59574
commit 9f9ff58a0d
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"strings"
"sync"
"text/template"
"time"
@ -120,11 +121,16 @@ type postCreationOptions struct {
oldStatus postStatus
}
var postCreationMutex sync.Mutex
func (p *post) createOrReplace(o *postCreationOptions) error {
err := p.checkPost()
if err != nil {
return err
}
// Prevent bad things
postCreationMutex.Lock()
defer postCreationMutex.Unlock()
// Check if path is already in use
if o.new || (p.Path != o.oldPath) {
// Post is new or post path was changed