summaryrefslogtreecommitdiff
path: root/reload.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-13 00:52:59 -0500
committerJeff Carr <[email protected]>2025-09-13 00:52:59 -0500
commit719287c3bfa349c74c2ce86b01299c97169ec3a8 (patch)
tree5a00c1e9d44d28511d27cc50f86f8d03a8655ae8 /reload.go
parent6654dbb4102ba0f725f7d82b5f26a7288a68699d (diff)
changes to Reload()v0.0.126
Diffstat (limited to 'reload.go')
-rw-r--r--reload.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/reload.go b/reload.go
index 5613f6c..99859ba 100644
--- a/reload.go
+++ b/reload.go
@@ -4,17 +4,33 @@ import (
"strings"
"time"
+ "go.wit.com/lib/config"
"go.wit.com/log"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
+// sets a flag that the repos have changed
+// used later by applications on exit to test if
+// the protobuf needs to be written to disk
+func reposChanged(b bool) {
+ config.SetChanged("repos", true)
+}
+
+// returns true based on os.Stat() only checks
+// seems to kinda work ok. goal is to avoid os.Exec() here for speed
+// this might be the 1 place where libgit2 would be a good idea
+func (repo *Repo) HasChanged() bool {
+ return repo.DidRepoChange()
+}
+
// does a fast check with os.Stat()
-// if the mtimes changed, does a full repo.Reload()
+// if the mtimes changed, does a full repo.ReloadForce()
func (repo *Repo) ReloadCheck() error {
if !repo.DidRepoChange() {
return nil
}
- err := repo.Reload()
+ reposChanged(true)
+ err := repo.ReloadForce()
if err != nil {
return err
}
@@ -22,7 +38,8 @@ func (repo *Repo) ReloadCheck() error {
}
// TODO: clean this up more, but it is working now more or less
-func (repo *Repo) Reload() error {
+func (repo *Repo) ReloadForce() error {
+ reposChanged(true)
// sometimes, on new repos, if .git/HEAD does not exist
// defective git daemons or badly configured repos, 'git clone' can fail
// if so, 'git fetch origin' can repair the state