diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-10-17 11:54:55 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-10-18 12:13:13 +0200 |
commit | ba35e69856900b6fc92681aa841cdcaefbb4b121 (patch) | |
tree | b9ffc699a99b2d6d947e1d53c383a1352ce93980 /hugolib/hugo_sites_build.go | |
parent | c7957c90e83ff2b2cc958bd61486a244f0fd8891 (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.go | 18 |
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) |