summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-07 02:37:34 -0500
committerJeff Carr <[email protected]>2025-10-07 02:37:34 -0500
commitcd5c29e5bcb1b2875baa687ddab0ccb3e69f94d5 (patch)
tree6d587651f7bd915d03cd34c051cbe633748fd31b /config.go
parent6bd10cf29ba546e80803874e0499d17aa2223330 (diff)
notsure if Validate is in lib/config package yetv0.0.152
Diffstat (limited to 'config.go')
-rw-r--r--config.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/config.go b/config.go
index 3068869..16d3048 100644
--- a/config.go
+++ b/config.go
@@ -7,7 +7,9 @@ import (
"errors"
"os"
"path/filepath"
+ "time"
+ "go.wit.com/lib/config"
"go.wit.com/lib/protobuf/bugpb"
"go.wit.com/log"
)
@@ -23,23 +25,28 @@ func (all *Repos) ConfigSave(fname string) error {
log.Infof("ConfigSave() filename '%s' invalid\n", fname)
return log.Errorf("ConfigSave() filename '%s' invalid\n", fname)
}
- return all.Save(fname)
+ return all.SaveValidate(fname)
}
// bypass name check "repos.pb"
-func (all *Repos) Save(fname string) error {
- data, err := all.Marshal()
+func (pb *Repos) SaveValidate(fname string) error {
+ if pb.Filename != fname {
+ log.Printf("gitpb.Repos.Filename mismatch '%s' != '%s'\n", pb.Filename, fname)
+ pb.Filename = fname
+ time.Sleep(5 * time.Second)
+ }
+ data, err := pb.Marshal()
if err != nil {
log.Info("gitpb proto.Marshal() failed len", len(data), err)
// often this is because strings have invalid UTF-8. This should probably be fixed in the protobuf code
// this might be fixed in the create code, but it can't hurt to try this as a last ditch effort here
log.Info("gitpb.ConfigSave() ATTEMPTING TO VALIDATE UTF-8 strings in the protobuf file")
- if err := all.tryValidate(); err != nil {
+ if err := pb.tryValidate(); err != nil {
log.Info("gitpb.ConfigSave() STILL FAILEd", err)
return err
} else {
// re-attempt Marshal() here
- data, err = all.Marshal()
+ data, err = pb.Marshal()
if err == nil {
// validate & sanitize strings worked
configWrite(fname, data)
@@ -49,7 +56,7 @@ func (all *Repos) Save(fname string) error {
}
return err
}
- configWrite(fname, data)
+ config.Save(pb)
return nil
}