summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-08 02:38:50 -0600
committerJeff Carr <[email protected]>2025-01-08 02:38:50 -0600
commitebda2ea222ed9f1d348d5d3e0cffb9c9f9c0acec (patch)
tree09b457c7cd588f3f47e65d53d26b531e1db5f795
parentd4a31b8e0bd7cf96b9e02bd3f3943d62059645d4 (diff)
keep working the problem
-rw-r--r--reload.go10
-rw-r--r--reloadMtime.go (renamed from mtime.go)11
2 files changed, 18 insertions, 3 deletions
diff --git a/reload.go b/reload.go
index 0f15698..5329561 100644
--- a/reload.go
+++ b/reload.go
@@ -2,8 +2,10 @@ package gitpb
import (
"strings"
+ "time"
"go.wit.com/log"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
// 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.reloadVersions()
repo.setRepoType()
+
+ // this is probably a good place & time to store these
+ repo.reloadMtimes()
+
repo.CheckDirty()
repo.setRepoState()
- // everything has been checked, now save the mtime's
- repo.updateMtimes()
+ // LastUpdate should always be the newest time
+ repo.Times.LastUpdate = timestamppb.New(time.Now())
return nil
}
diff --git a/mtime.go b/reloadMtime.go
index 8ab07b8..7c18e9f 100644
--- a/mtime.go
+++ b/reloadMtime.go
@@ -141,7 +141,7 @@ func (repo *Repo) changedIndex() bool {
return true
}
-func (repo *Repo) updateMtimes() bool {
+func (repo *Repo) reloadMtimes() bool {
var changed bool
if repo.Times == nil {
repo.Times = new(GitTimes)
@@ -175,6 +175,15 @@ func (repo *Repo) DidRepoChange() bool {
// todo: do something with CheckDirty()
// 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)
return false
}