diff options
Diffstat (limited to 'Load.go')
| -rw-r--r-- | Load.go | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -11,6 +11,7 @@ package forgepb import ( "errors" + "os" "go.wit.com/lib/ENV" "go.wit.com/lib/config" @@ -60,24 +61,24 @@ func (f *Forge) reposCacheLoad() error { return err } -/* -func (f *Forge) loadPatchsets() error { - f.Patchsets = NewSets() - - data, err := os.ReadFile(config.Get("PatchPB")) - if err != nil { - return err +func (f *Forge) patchesCacheLoad() error { + if f.Patches != nil { + return errors.New("already loaded") + } + f.Patches = NewPatches() + err := config.LoadAppnameCache(f.Patches, "forge") + if errors.Is(err, os.ErrNotExist) { + // is a new file + f.Patches.Save() + return os.ErrNotExist } - - err = f.Patchsets.Unmarshal(data) if err != nil { - log.Infof("LoadPatchsets() proto.Marshal() error %v\n", err) - return err + log.Printf("patchesCacheLoad() failed err (%v) filename (%s)\n", err, f.Patches.Filename) + panic("failed to load patches") } - // log.Infof("LoadPatchsets() found %d patches.\n", f.Patchsets.Len()) - return nil + ENV.SetGlobal("lib/forgepb", "PatchesPB", f.Patches.Filename) + return err } -*/ func makeDefaultConfig() (*ForgeConfigs, error) { cfg := NewForgeConfigs() |
