diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 20:10:01 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 20:10:01 +0200 |
| commit | aa24cfb344b1b3eaef7217d996359023cd72ba28 (patch) | |
| tree | ee0d981d3add58451a83de13ac56be4a8b165eea /internal/engine | |
| parent | 00aae60378982902b871a87850e0ed427b28a347 (diff) | |
| download | krino-aa24cfb344b1b3eaef7217d996359023cd72ba28.tar.gz krino-aa24cfb344b1b3eaef7217d996359023cd72ba28.zip | |
plan 8: fuzz decoders; fold ẞ and invalid UTF-8 correctly, refuse non-UTF-8 paths in krino new
Diffstat (limited to 'internal/engine')
| -rw-r--r-- | internal/engine/match.go | 10 |
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)"} |
