Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-17 12:54:55 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-18 13:13:13 +0300
commitba35e69856900b6fc92681aa841cdcaefbb4b121 (patch)
treeb9ffc699a99b2d6d947e1d53c383a1352ce93980 /hugolib/hugo_sites_build.go
parentc7957c90e83ff2b2cc958bd61486a244f0fd8891 (diff)
Add a cross process build lock and use it in the archetype content builder
Fixes #9048
Diffstat (limited to 'hugolib/hugo_sites_build.go')
-rw-r--r--hugolib/hugo_sites_build.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index ab3603cc0..6f3955b80 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -44,19 +44,17 @@ import (
// Build builds all sites. If filesystem events are provided,
// this is considered to be a potential partial rebuild.
func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
- if h.running {
- // Make sure we don't trigger rebuilds in parallel.
- h.runningMu.Lock()
- defer h.runningMu.Unlock()
- } else {
- defer func() {
- h.Close()
- }()
- }
-
ctx, task := trace.NewTask(context.Background(), "Build")
defer task.End()
+ if !config.NoBuildLock {
+ unlock, err := h.BaseFs.LockBuild()
+ if err != nil {
+ return errors.Wrap(err, "failed to acquire a build lock")
+ }
+ defer unlock()
+ }
+
errCollector := h.StartErrorCollector()
errs := make(chan error)