diff options
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -81,7 +81,7 @@ func (all *Repos) tryValidate() error { // load the repos.pb file. I shouldn't really matter if this // fails. the file should be autogenerated. This is used // locally just for speed -func (all *Repos) ConfigLoad() error { +func (all *Repos) ConfigLoadOld() error { if os.Getenv("FORGE_REPOSDIR") == "" { homeDir, _ := os.UserHomeDir() fullpath := filepath.Join(homeDir, ".config/forge") @@ -98,7 +98,33 @@ func (all *Repos) ConfigLoad() error { } // this means the forge.pb file exists and was read if len(data) == 0 { - all.sampleConfig() // causes nil panic + return errors.New("gitpb.ConfigLoad() repos.pb is empty") + } + 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 (all *Repos) ConfigLoad(cfgname string) error { + var data []byte + var err error + + if data, err = loadFile(cfgname); err != nil { + // something went wrong loading the file + // all.sampleConfig() // causes nil panic + return err + } + // this means the forge.pb file exists and was read + if len(data) == 0 { return errors.New("gitpb.ConfigLoad() repos.pb is empty") } err = all.Unmarshal(data) |
