diff options
| author | Jeff Carr <[email protected]> | 2025-10-27 10:45:25 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-27 10:45:25 -0500 |
| commit | 9e98e0b36d794d4acb7bc81909ee94598a43b37c (patch) | |
| tree | 1144dea4a8676d90eb024651efad58591e3c6ceb /cache.go | |
| parent | b7e832d8a5a00ed6647735b8c9a3151cb8496899 (diff) | |
work on a Cache setting concept
Diffstat (limited to 'cache.go')
| -rw-r--r-- | cache.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/cache.go b/cache.go new file mode 100644 index 0000000..0957b26 --- /dev/null +++ b/cache.go @@ -0,0 +1,51 @@ +// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT. +// go install go.wit.com/apps/autogenpb@latest +// +// This file was autogenerated with autogenpb: +// autogenpb v0.5.25-2-g30e8de2 Built on 2025/10/16 09:16:09 ( 3 m) +// Theese sort.pb.go and marshal.pb.go files are autogenerated +// The autogenpb sources have example .proto files with instructions +// + +package forgepb + +import ( + "errors" + "os" + "path/filepath" + + "go.wit.com/lib/config" + "go.wit.com/lib/env" + "go.wit.com/log" +) + +func (f *Forge) configureCache(cacheName string) error { + // construct the full file name + fullname := config.MakeConfigFilename("forge", cacheName) + + // try to load the file + f.cache = new(Cache) + f.cache.Filename = fullname + if env.Verbose() { + log.Info("configCache() attempting to ReLoad()", fullname) + } + err := config.ReLoad(f.cache) + if errors.Is(err, os.ErrNotExist) { + // is a new file + return os.ErrNotExist + } + if err != nil { + log.Printf("patchesCacheLoad() failed err (%v) filename (%s)\n", err, f.cache.Filename) + panic("failed to load patches") + } + if cacheName == "gosrc" { + f.cache.Name = cacheName + f.cache.Filename = fullname + gosrc := filepath.Join(env.Get("homeDir"), "go/src") + f.cache.Dirs = []string{gosrc} + f.cache.Save() + } + env.SetGlobal("lib/forgepb", "cache", cacheName) + env.SetGlobal("lib/forgepb", "cacheTEXT", f.cache.Filename) + return err +} |
