keep working the problem
This commit is contained in:
parent
d4a31b8e0b
commit
ebda2ea222
10
reload.go
10
reload.go
|
@ -2,8 +2,10 @@ package gitpb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: fix and clean this up. this is a work in progress
|
// TODO: fix and clean this up. this is a work in progress
|
||||||
|
@ -19,11 +21,15 @@ func (repo *Repo) Reload() error {
|
||||||
repo.ParseGoSum() // also sets GoPrimitive
|
repo.ParseGoSum() // also sets GoPrimitive
|
||||||
repo.reloadVersions()
|
repo.reloadVersions()
|
||||||
repo.setRepoType()
|
repo.setRepoType()
|
||||||
|
|
||||||
|
// this is probably a good place & time to store these
|
||||||
|
repo.reloadMtimes()
|
||||||
|
|
||||||
repo.CheckDirty()
|
repo.CheckDirty()
|
||||||
repo.setRepoState()
|
repo.setRepoState()
|
||||||
|
|
||||||
// everything has been checked, now save the mtime's
|
// LastUpdate should always be the newest time
|
||||||
repo.updateMtimes()
|
repo.Times.LastUpdate = timestamppb.New(time.Now())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ func (repo *Repo) changedIndex() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) updateMtimes() bool {
|
func (repo *Repo) reloadMtimes() bool {
|
||||||
var changed bool
|
var changed bool
|
||||||
if repo.Times == nil {
|
if repo.Times == nil {
|
||||||
repo.Times = new(GitTimes)
|
repo.Times = new(GitTimes)
|
||||||
|
@ -175,6 +175,15 @@ func (repo *Repo) DidRepoChange() bool {
|
||||||
// todo: do something with CheckDirty()
|
// todo: do something with CheckDirty()
|
||||||
// return true
|
// return true
|
||||||
}
|
}
|
||||||
|
if repo.Times.LastUpdate == nil {
|
||||||
|
log.Info("repo.Reload() was never run")
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
if repo.Times.LastUpdate.Seconds < repo.Times.MtimeHead.Seconds {
|
||||||
|
log.Info("SHOULD RUN Reload() here", repo.Times.MtimeHead.Seconds-repo.Times.LastUpdate.Seconds, "secs diff")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
// log.Info("DidRepoChange() is false", repo.FullPath)
|
// log.Info("DidRepoChange() is false", repo.FullPath)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
Loading…
Reference in New Issue