diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:39:37 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:39:37 +0200 |
| commit | c09020c2fb01da24d5befbed78ce3b73b5efbe4c (patch) | |
| tree | 8cd1086588988fafaf238aed8a38a7ec85b0afa3 /internal/engine/facts.go | |
| parent | 3990586a85e91923c0a3ae1a1f0f61420db555ac (diff) | |
| download | krino-c09020c2fb01da24d5befbed78ce3b73b5efbe4c.tar.gz krino-c09020c2fb01da24d5befbed78ce3b73b5efbe4c.zip | |
content tests are three-valued: unknown when unreadable or read in part
Diffstat (limited to 'internal/engine/facts.go')
| -rw-r--r-- | internal/engine/facts.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/engine/facts.go b/internal/engine/facts.go index ccdf18d..c510b20 100644 --- a/internal/engine/facts.go +++ b/internal/engine/facts.go @@ -118,6 +118,7 @@ type facts struct { contentDone bool // extraction was attempted contentErr error // why it failed + partialErr error // extract.ErrPartial: a keyword not found may be in the unread part answers map[string]bool // by cond.KeywordKey, once extracted } @@ -171,7 +172,7 @@ func (f *facts) ContentContains(opt cond.Options, keywords []string) (int, error return i, nil } } - return -1, nil + return -1, f.partialErr } // extract reads the file's text and answers every keyword of the directory, @@ -180,6 +181,10 @@ func (f *facts) extract(opt cond.Options, keywords []string) { f.contentDone = true text, err := f.run.e.Extract.Text(f.run.ctx, f.file.Path, f.file.Size, f.run.d.Settings.MaxRead) switch { + case errors.Is(err, extract.ErrPartial): + // Partly read: the keywords found in it are answered; one not found + // is unknown (ContentContains), and nothing is cached (plan 11). + f.partialErr = err case errors.Is(err, extract.ErrUnsupported): // A format with no text cannot contain a keyword: every answer is // no, with no warning, and the answers are cached like any other @@ -203,7 +208,7 @@ func (f *facts) extract(opt cond.Options, keywords []string) { } f.answers[k.Key()] = strings.Contains(t, k.Norm) } - if id, ok := f.cacheID(); ok { + if id, ok := f.cacheID(); ok && f.partialErr == nil { f.run.cache.Store(id, f.answers) } } |
