diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-10-17 11:54:55 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-10-18 12:13:13 +0200 |
commit | ba35e69856900b6fc92681aa841cdcaefbb4b121 (patch) | |
tree | b9ffc699a99b2d6d947e1d53c383a1352ce93980 /create | |
parent | c7957c90e83ff2b2cc958bd61486a244f0fd8891 (diff) | |
download | hugo-ba35e69856900b6fc92681aa841cdcaefbb4b121.tar.gz hugo-ba35e69856900b6fc92681aa841cdcaefbb4b121.zip |
Add a cross process build lock and use it in the archetype content builder
Fixes #9048
Diffstat (limited to 'create')
-rw-r--r-- | create/content.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/create/content.go b/create/content.go index 714939f4c..b006e0f2c 100644 --- a/create/content.go +++ b/create/content.go @@ -53,6 +53,12 @@ draft: true // NewContent creates a new content file in h (or a full bundle if the archetype is a directory) // in targetPath. func NewContent(h *hugolib.HugoSites, kind, targetPath string) error { + unlock, err := h.BaseFs.LockBuild() + if err != nil { + return fmt.Errorf("failed to acquire a build lock: %s", err) + } + defer unlock() + cf := hugolib.NewContentFactory(h) if kind == "" { @@ -138,7 +144,7 @@ func (b *contentBuilder) buildDir() error { } - if err := b.h.Build(hugolib.BuildCfg{SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil { + if err := b.h.Build(hugolib.BuildCfg{NoBuildLock: true, SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil { return err } @@ -200,7 +206,7 @@ func (b *contentBuilder) buildFile() error { }) } - if err := b.h.Build(hugolib.BuildCfg{SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil { + if err := b.h.Build(hugolib.BuildCfg{NoBuildLock: true, SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil { return err } |