mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
lazy: Reset error in Reset
To prevent sticky errors on server rebuilds. Fixes #7043 Closes #9194
This commit is contained in:
parent
0eaaa8fee3
commit
b10381fbe0
2 changed files with 20 additions and 0 deletions
|
@ -136,6 +136,7 @@ func (ini *Init) shouldInitialize() bool {
|
||||||
// Reset resets the current and all its dependencies.
|
// Reset resets the current and all its dependencies.
|
||||||
func (ini *Init) Reset() {
|
func (ini *Init) Reset() {
|
||||||
mu := ini.init.ResetWithLock()
|
mu := ini.init.ResetWithLock()
|
||||||
|
ini.err = nil
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
for _, d := range ini.children {
|
for _, d := range ini.children {
|
||||||
d.Reset()
|
d.Reset()
|
||||||
|
|
|
@ -220,3 +220,22 @@ func TestInitBranchOrder(t *testing.T) {
|
||||||
|
|
||||||
c.Assert(state.V2, qt.Equals, "ABAB")
|
c.Assert(state.V2, qt.Equals, "ABAB")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See issue 7043
|
||||||
|
func TestResetError(t *testing.T) {
|
||||||
|
c := qt.New(t)
|
||||||
|
r := false
|
||||||
|
i := New().Add(func() (interface{}, error) {
|
||||||
|
if r {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, errors.New("r is false")
|
||||||
|
})
|
||||||
|
_, err := i.Do()
|
||||||
|
c.Assert(err, qt.IsNotNil)
|
||||||
|
i.Reset()
|
||||||
|
r = true
|
||||||
|
_, err = i.Do()
|
||||||
|
c.Assert(err, qt.IsNil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue