aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--internal/engine/exclude_test.go28
-rw-r--r--internal/extract/extract.go5
3 files changed, 34 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80355e1..93b0854 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,8 @@
krino could not read; an exclude holds on an unknown only when the text
could change its answer; `explain` shows `?`. A document read only in part
answers the keywords found in what was read, and leaves the others
- unknown.
+ unknown; its answers are never cached, and keyword caches written by
+ 0.0.7 are discarded.
- `krino log` marks a run "(partly undone)" while some of its reversible
steps are not reversed, and "(undone)" only once every one is.
- Tests read real documents made by LibreOffice and pandoc (docx, odt, ods,
diff --git a/internal/engine/exclude_test.go b/internal/engine/exclude_test.go
index 8308a82..5a758bb 100644
--- a/internal/engine/exclude_test.go
+++ b/internal/engine/exclude_test.go
@@ -455,3 +455,31 @@ func TestExplainLeavesTheCacheAlone(t *testing.T) {
t.Errorf("explain removed the cache: %v", err)
}
}
+
+// TestPartlyReadableDocumentIsNotCached: a partial read's answers never
+// enter the keyword cache, so a second run with the cache still sets the
+// file aside (plan 11 review M2).
+func TestPartlyReadableDocumentIsNotCached(t *testing.T) {
+ h, dl := excludeTree(t, map[string]string{})
+ os.MkdirAll(dl, 0o755)
+ partDocx(t, filepath.Join(dl, "part.docx"), "good body text")
+ main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": `
+(path "~/dl")
+(exclude (content "confidential"))
+(rule "all" (move "Out"))
+`})
+ for run := 1; run <= 2; run++ {
+ e, errs := Load(main)
+ if len(errs) > 0 {
+ t.Fatal(errs)
+ }
+ e.CacheDir = filepath.Join(h, "cache")
+ r, err := e.Match(context.Background(), e.Dirs[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(r.Matched) != 1 || !strings.HasSuffix(r.Matched[0].Excluded, "(content unreadable)") {
+ t.Fatalf("run %d: matched = %+v; want part.docx set aside", run, r.Matched)
+ }
+ }
+}
diff --git a/internal/extract/extract.go b/internal/extract/extract.go
index 0843c42..c0f0262 100644
--- a/internal/extract/extract.go
+++ b/internal/extract/extract.go
@@ -17,7 +17,10 @@ import (
// Version is the version of the text this package extracts. Bump it
// whenever a change could make any format's text differ, so every keyword
// cache built from the old text is discarded (Fingerprint).
-const Version = 2
+//
+// 3: a document read only in part (ErrPartial) and text that turns binary
+// answer differently from 0.0.7, whose caches may hold their answers.
+const Version = 3
var (
// ErrUnsupported is returned when the format carries no text krino