feat(PROJ-45): IMAP per-folder UID-tracking, UIDVALIDITY-check + reindex OCR protection
- scheduler.go: BUG-1 fix — preserve stored uid_validity when server returns 0 - scheduler.go: BUG-2 fix — replace inline switch with DecideResync() call - scheduler.go: SetAuditLogger wired; imap_uidvalidity_reset audit event - cmd_reindex.go: read existing attachment_text before IndexSync to prevent Manticore REPLACE INTO from wiping OCR text written by the OCR worker Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,19 @@ func runReindex(args []string) {
|
||||
}
|
||||
|
||||
idx := idxMgr.ForTenant(tenantID)
|
||||
|
||||
// Preserve existing OCR text — IndexSync uses REPLACE which would
|
||||
// otherwise wipe attachment_text written by the OCR worker.
|
||||
// Only read from the index when the DB confirms OCR has run (ocr_chars>0).
|
||||
_, ocrChars, _ := mailStore.GetOCRMeta(ctx, id)
|
||||
if ocrChars > 0 {
|
||||
if reader, ok := idx.(index.AttachmentTextReader); ok {
|
||||
if existing, err := reader.GetAttachmentText(id); err == nil && existing != "" {
|
||||
doc.AttachmentText = existing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := idx.IndexSync(doc); err != nil {
|
||||
logger.Warn("reindex: index failed", "id", id, "err", err)
|
||||
errors++
|
||||
|
||||
Reference in New Issue
Block a user