From f1dbe15854ba41e5f4706a436a5324b0a4434122 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 2 Nov 2025 21:09:57 -0600 Subject: work on a stats tag cache file --- repo.Stats.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'repo.Stats.go') diff --git a/repo.Stats.go b/repo.Stats.go index 03e10d8..d71bf60 100644 --- a/repo.Stats.go +++ b/repo.Stats.go @@ -20,13 +20,15 @@ func initStats() { } } -func (r *Repo) LoadStats() (*Stats, error) { - filename := filepath.Join(r.FullPath, ".git/", "stats.pb") - if fileExists(filename) { - newfilename := filepath.Join(r.FullPath, ".git/origin.pb") - os.Rename(filename, newfilename) +func (r *Repo) LoadStats(remote string) (*Stats, error) { + fullname := filepath.Join(r.FullPath, ".git/", remote+".pb") + if !fileExists(fullname) { + return nil, os.ErrNotExist } - return r.Stats(), nil + stats := NewStats() + stats.Filename = fullname + err := config.ReLoad(stats) + return stats, err } func (r *Repo) Stats() *Stats { @@ -55,7 +57,7 @@ func (r *Repo) Stats() *Stats { return origin } -// todo: move this somewhere +// todo: move this somewhere. where should it go? // fileExists checks if a file exists and is not a directory. func fileExists(filename string) bool { info, err := os.Stat(filename) -- cgit v1.2.3