mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Add a cross process build lock and use it in the archetype content builder
Fixes #9048
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user