From cd5c29e5bcb1b2875baa687ddab0ccb3e69f94d5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 7 Oct 2025 02:37:34 -0500 Subject: notsure if Validate is in lib/config package yet --- config.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'config.go') 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 } -- cgit v1.2.3