aboutsummaryrefslogtreecommitdiffhomepage
path: root/deps
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-07-11 19:23:22 +0200
committerBjørn Erik Pedersen <[email protected]>2018-07-11 20:40:04 +0200
commit6b6dcb44a014699c289bf32fe57d4c4216777be0 (patch)
treeee7c4a831be73ec9e1656690550bccb8ee913f97 /deps
parentd96f2a460f58e91d8f6253a489d4879acfec6916 (diff)
downloadhugo-6b6dcb44a014699c289bf32fe57d4c4216777be0.tar.gz
hugo-6b6dcb44a014699c289bf32fe57d4c4216777be0.zip
Flush partialCached cache on rebuilds
Fixes #4931
Diffstat (limited to 'deps')
-rw-r--r--deps/deps.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/deps/deps.go b/deps/deps.go
index b32c7e2e9..5a97ec7f2 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -1,6 +1,7 @@
package deps
import (
+ "sync"
"time"
"github.com/gohugoio/hugo/common/loggers"
@@ -22,6 +23,7 @@ import (
// There will be normally only one instance of deps in play
// at a given time, i.e. one per Site built.
type Deps struct {
+
// The logger to use.
Log *jww.Notepad `json:"-"`
@@ -69,6 +71,30 @@ type Deps struct {
// Timeout is configurable in site config.
Timeout time.Duration
+
+ // BuildStartListeners will be notified before a build starts.
+ BuildStartListeners *Listeners
+}
+
+type Listeners struct {
+ sync.Mutex
+
+ // A list of funcs to be notified about an event.
+ listeners []func()
+}
+
+func (b *Listeners) Add(f func()) {
+ b.Lock()
+ defer b.Unlock()
+ b.listeners = append(b.listeners, f)
+}
+
+func (b *Listeners) Notify() {
+ b.Lock()
+ defer b.Unlock()
+ for _, notify := range b.listeners {
+ notify()
+ }
}
// ResourceProvider is used to create and refresh, and clone resources needed.
@@ -168,6 +194,7 @@ func New(cfg DepsCfg) (*Deps, error) {
ResourceSpec: resourceSpec,
Cfg: cfg.Language,
Language: cfg.Language,
+ BuildStartListeners: &Listeners{},
Timeout: time.Duration(timeoutms) * time.Millisecond,
}
@@ -210,6 +237,8 @@ func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) {
return nil, err
}
+ d.BuildStartListeners = &Listeners{}
+
return &d, nil
}