fix(scanner): classify .docx as reflowable — was landing format_group unknown

.docx is accepted for ingest but the format-group switch had no case
for it, so every DOCX row stored format_group 'unknown' with
is_reflowable=false. Extract the classification switch into a pure
classifyFormatGroup helper with a table test, and classify .docx
reflowable like the other reflowable text formats (.rtf/.doc stay out
until they are readable client-side). Existing rows: dev alice (DOCX)
reclassified by hand; production rows reclassify on rescan.
This commit is contained in:
John O'Keefe
2026-10-03 14:17:58 -04:00
parent ad1ad11fb5
commit f2629942e4
2 changed files with 57 additions and 22 deletions
+31
View File
@@ -119,3 +119,34 @@ func TestProcessDirtyDirectories_CollectsReadyDirs(t *testing.T) {
scanner.dirtyDirsMu.RUnlock()
assert.Equal(t, 0, count, "Ready directory should be removed from dirty list")
}
func TestClassifyFormatGroup(t *testing.T) {
tests := []struct {
name string
ext string
epubFixed bool
group string
reflow bool
fixed bool
}{
{"EPUB reflowable", ".epub", false, "reflowable", true, false},
{"EPUB fixed-layout", ".epub", true, "fixed_layout", false, true},
{"MOBI", ".mobi", false, "reflowable", true, false},
{"FB2", ".fb2", false, "reflowable", true, false},
{"TXT", ".txt", false, "reflowable", true, false},
{"DOCX (was unknown before the fix)", ".docx", false, "reflowable", true, false},
{"PDF", ".pdf", false, "fixed_layout", false, true},
{"DJVU", ".djvu", false, "fixed_layout", false, true},
{"CBZ", ".cbz", false, "comic_archive", false, true},
{"unrecognized extension", ".xyz", false, "unknown", false, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
group, reflow, fixed := classifyFormatGroup(tt.ext, tt.epubFixed)
if group != tt.group || reflow != tt.reflow || fixed != tt.fixed {
t.Errorf("classifyFormatGroup(%q, %v) = (%q, %v, %v), want (%q, %v, %v)",
tt.ext, tt.epubFixed, group, reflow, fixed, tt.group, tt.reflow, tt.fixed)
}
})
}
}