die on protobuf mis-match

This commit is contained in:
Jeff Carr 2025-01-19 00:36:48 -06:00
parent 723ca5e829
commit 84c9fe2bfc
1 changed files with 19 additions and 1 deletions

View File

@ -56,7 +56,25 @@ func (all *Repos) ConfigLoad() error {
all.sampleConfig() // causes nil panic
return errors.New("gitpb.ConfigLoad() repos.pb is empty")
}
return all.Unmarshal(data)
err = all.Unmarshal(data)
test := NewRepos()
if test.Uuid != all.Uuid {
log.Log(WARN, "uuids do not match", test.Uuid, all.Uuid)
deleteProtobufFile(cfgname)
}
if test.Version != all.Version {
log.Log(WARN, "versions do not match", test.Version, all.Version)
deleteProtobufFile(cfgname)
}
log.Log(INFO, cfgname, "protobuf versions and uuid match", all.Uuid, all.Version)
return err
}
func deleteProtobufFile(filename string) {
log.Log(WARN, "The protobuf file format has changed for", filename)
log.Log(WARN, "You must delete", filename)
log.Log(WARN, "This file will be recreated")
os.Exit(-1)
}
func (all *Repos) sampleConfig() {