diff options
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) |