fix: correct duplicate message reporting in Go implementation

- Add DocumentSkippedError custom error type to distinguish between skipped and stored documents
- Fix counter bug where skipped messages were incorrectly reported as "stored"
- Enhance status reporting to show "X skipped as duplicates" for better visibility
- Fix Rust implementation binary attachment handling to support all file types (images, PDFs, etc.)
- Update test scripts to use correct binary names (mail2couch-go, mail2couch-rs)
- Add comprehensive test configurations for implementation comparison

Before: "Summary: Processed 30 messages, stored 30 new messages" (misleading when all were duplicates)
After: "Summary: Processed 30 messages, stored 0 new messages" with detailed "Stored 0/30 messages from INBOX (30 skipped as duplicates)"

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2025-08-04 00:36:01 +02:00
commit 436276f0ef
9 changed files with 127 additions and 18 deletions

View file

@ -15,6 +15,15 @@ import (
"mail2couch/mail"
)
// DocumentSkippedError indicates that a document was skipped because it already exists
type DocumentSkippedError struct {
DocumentID string
}
func (e *DocumentSkippedError) Error() string {
return fmt.Sprintf("document %s already exists, skipped", e.DocumentID)
}
// Client wraps the Kivik client
type Client struct {
*kivik.Client
@ -149,7 +158,7 @@ func (c *Client) StoreMessage(ctx context.Context, dbName string, doc *MailDocum
}
if exists {
return nil // Document already exists, skip
return &DocumentSkippedError{DocumentID: doc.ID}
}
// Store the document first (without attachments)