diff options
| author | Jeff Carr <[email protected]> | 2025-10-12 05:41:34 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-12 05:41:34 -0500 |
| commit | 10a8d81b1384b31a885f101b986726dfcd41a54a (patch) | |
| tree | 1623c0beb3896ae089d1774b411678ce5657b4be | |
| parent | fa1cc5d28ea09cc70c6fbff7bfc65694624acd6d (diff) | |
wasn't setting Filename after Load()
| -rw-r--r-- | load.go | 13 | ||||
| -rw-r--r-- | save.go | 2 |
2 files changed, 10 insertions, 5 deletions
@@ -72,10 +72,11 @@ func LoadCache(pb proto.Message, argname string, protoname string) error { fullpath := filepath.Join(cacheDir, argname) os.MkdirAll(fullpath, os.ModePerm) fullname := filepath.Join(fullpath, protoname+".pb") - SetFilename(pb, fullname) - return Load(pb) + _, err := SetFilename(pb, fullname) + return errors.Join(err, Load(pb)) } +// this logic isn't great yet func Load(pb proto.Message) error { fullname, err := GetFilename(pb) if err != nil { @@ -112,10 +113,14 @@ func Load(pb proto.Message) error { err = errors.Join(err, errors.New("pb uuid is:"+pbuuid)) return err } + _, err := SetFilename(pb, fullname) + if err != nil { + return err + } worked = true } if !worked { - return fmt.Errorf("unknown filetype %s", fullname) + return fmt.Errorf("unknown filetype '%s'", fullname) } newver, _ := GetString(pb, "version") if ver != newver { @@ -139,7 +144,7 @@ func LoadFile(pb proto.Message, fullname string) error { return loadPB(pb, fullname) } - return fmt.Errorf("unknown filetype %s", fullname) + return fmt.Errorf("unknown filetype '%s'", fullname) } func loadPB(pb proto.Message, fullname string) error { @@ -35,7 +35,7 @@ func SavePB(pb proto.Message, fullname string) error { if strings.HasSuffix(fullname, ".json") { return saveJSON(pb) } - return fmt.Errorf("unknown filetype %s", fullname) + return fmt.Errorf("unknown filetype '%s'", fullname) } func saveProto(pb proto.Message, fullname string) error { |
