die on protobuf mis-match
This commit is contained in:
parent
723ca5e829
commit
84c9fe2bfc
20
config.go
20
config.go
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue