Pkg: cache state when it is correct

We forgot to cache the state when we are converged. This avoids
repetitive checking when we hit repeated backpoke()'s for example.
This commit is contained in:
James Shubin
2016-05-14 12:23:48 -04:00
parent 3aaa80974e
commit ba7ef0788e

9
pkg.go
View File

@@ -157,7 +157,7 @@ func (obj *PkgRes) Watch(processChan chan Event) {
if exit, send = obj.ReadEvent(&event); exit { if exit, send = obj.ReadEvent(&event); exit {
return // exit return // exit
} }
//dirty = false // these events don't invalidate state dirty = false // these events don't invalidate state
case _ = <-cuuid.ConvergedTimer(): case _ = <-cuuid.ConvergedTimer():
cuuid.SetConverged(true) // converged! cuuid.SetConverged(true) // converged!
@@ -286,10 +286,12 @@ func (obj *PkgRes) CheckApply(apply bool) (checkok bool, err error) {
fallthrough fallthrough
case "newest": case "newest":
if validState { if validState {
return true, nil // state is correct, exit! obj.isStateOK = true // reset
return true, nil // state is correct, exit!
} }
default: // version string default: // version string
if obj.State == data.Version && data.Version != "" { if obj.State == data.Version && data.Version != "" {
obj.isStateOK = true // reset
return true, nil return true, nil
} }
} }
@@ -333,7 +335,8 @@ func (obj *PkgRes) CheckApply(apply bool) (checkok bool, err error) {
return false, err // fail return false, err // fail
} }
log.Printf("%v: Set: %v success!", obj.fmtNames(StrListIntersection(applyPackages, obj.getNames())), obj.State) log.Printf("%v: Set: %v success!", obj.fmtNames(StrListIntersection(applyPackages, obj.getNames())), obj.State)
return false, nil // success obj.isStateOK = true // reset
return false, nil // success
} }
type PkgUUID struct { type PkgUUID struct {