forked from tangled.org/core
Monorepo for Tangled

knotserver/git: construct a more unique cache key

The previous cache key was just the path, so files that are often common
across git repos like '.gitignore' etc. show a cached "last commit" time
from another repository. Pretty funny.

This uses the current plumbing.Hash.String():path as the key which
should theoretically be unique to each repository.

Changed files
+3 -2
knotserver
git
+3 -2
knotserver/git/git.go
··· 300 300 } 301 301 302 302 func (g *GitRepo) LastCommitForPath(path string) (*object.Commit, error) { 303 + cacheKey := fmt.Sprintf("%s:%s", g.h.String(), path) 303 304 cacheMu.RLock() 304 - if commit, found := commitCache.Get(path); found { 305 + if commit, found := commitCache.Get(cacheKey); found { 305 306 cacheMu.RUnlock() 306 307 return commit.(*object.Commit), nil 307 308 } ··· 330 331 } 331 332 332 333 cacheMu.Lock() 333 - commitCache.Set(path, commit, 1) 334 + commitCache.Set(cacheKey, commit, 1) 334 335 cacheMu.Unlock() 335 336 336 337 return commit, nil