mirror of
https://github.com/danog/gojekyll.git
synced 2024-11-30 06:08:57 +01:00
Mutex the cache
This commit is contained in:
parent
8bee1ea96a
commit
e5e96cef84
4
cache/cache.go
vendored
4
cache/cache.go
vendored
@ -7,9 +7,11 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var disableCache = false
|
||||
var cacheMx sync.Mutex
|
||||
|
||||
func init() {
|
||||
s := os.Getenv("GOJEKYLL_DISABLE_CACHE")
|
||||
@ -51,6 +53,8 @@ func WithFile(header string, content string, fn func() (string, error)) (string,
|
||||
if err := os.MkdirAll(filepath.Dir(cachefile), 0700); err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer cacheMx.Unlock()
|
||||
cacheMx.Lock()
|
||||
if err := ioutil.WriteFile(cachefile, []byte(s), 0600); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user