aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/match.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/engine/match.go')
-rw-r--r--internal/engine/match.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/engine/match.go b/internal/engine/match.go
index 1a8077a..b922829 100644
--- a/internal/engine/match.go
+++ b/internal/engine/match.go
@@ -17,6 +17,7 @@ import (
"krino/internal/cond"
"krino/internal/config"
"krino/internal/kwcache"
+ "krino/internal/norm"
"krino/internal/plan"
"krino/internal/scan"
"krino/internal/xdg"
@@ -296,6 +297,13 @@ func (e *Engine) Explain(ctx context.Context, path string) (*Explanation, error)
return &Explanation{Dir: d, File: sf, Skip: skip, Excludes: excludes, Excluded: excluded, Rules: rules}, nil
}
+// cacheFingerprint identifies what a cached keyword answer depends on
+// besides the file: the extractor (its version and tools) and the
+// normalisation version. A cache written under any other is discarded.
+func (e *Engine) cacheFingerprint() string {
+ return fmt.Sprintf("%s norm%d", e.Extract.Fingerprint(), norm.Version)
+}
+
// cacheFile is d's keyword cache file.
func (e *Engine) cacheFile(d *Dir) string {
return filepath.Join(e.CacheDir, d.Name+".cache")
@@ -308,7 +316,7 @@ func (e *Engine) openCache(run *matchRun) []string {
if e.CacheDir == "" || len(run.d.ContentKeywords) == 0 {
return nil
}
- c, err := kwcache.Load(e.cacheFile(run.d), e.Extract.Fingerprint())
+ c, err := kwcache.Load(e.cacheFile(run.d), e.cacheFingerprint())
run.cache = c
if err != nil {
return []string{"cache: " + err.Error() + " (starting a new one)"}