Skip to content

Support modern Apple Mail V10 directory layout#163

Merged
wesm merged 2 commits intomainfrom
import-apple-mail
Feb 26, 2026
Merged

Support modern Apple Mail V10 directory layout#163
wesm merged 2 commits intomainfrom
import-apple-mail

Conversation

@wesm
Copy link
Owner

@wesm wesm commented Feb 26, 2026

Summary

  • Modern Apple Mail (macOS 13+) uses <GUID>/Data/Messages/ inside .mbox directories instead of a direct Messages/ subdirectory, causing import-emlx to find 0 mailboxes
  • Add findMessagesDir() to probe both legacy and V10 layouts, and MsgDir field to Mailbox so the importer reads from the correct path
  • Filter UUID path components from labels so account GUIDs don't leak into mailbox names

Test plan

  • All existing discovery and importer tests pass (no regressions)
  • New tests cover V10 walk, V10 single-mailbox auto-detect, V10 partial-emlx skipping, UUID filtering in labels, and isUUID edge cases
  • Manual test with real ~/Library/Mail/V10 directory

Fixes #157

🤖 Generated with Claude Code

Modern Apple Mail (macOS 13+) uses a different directory structure
inside .mbox directories: <GUID>/Data/Messages/ instead of the
legacy Messages/ directly under .mbox. This caused import-emlx to
find 0 mailboxes when pointed at ~/Library/Mail/V10.

Add findMessagesDir() to probe both legacy and V10 layouts, add
MsgDir field to Mailbox struct so the importer uses the actual
Messages path, and filter UUID path components from labels.

Fixes #157

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@roborev-ci
Copy link

roborev-ci bot commented Feb 26, 2026

roborev: Combined Review (63eeaee)

Summary Verdict: All reviewers agree that the code is clean and no issues were found.


Synthesized from 4 reviews (agents: codex, gemini | types: default, security)

findMessagesDir() short-circuited on the first candidate found
(legacy Messages/), even if it was empty. When a stale empty
Messages/ coexists with a populated V10 <GUID>/Data/Messages/,
the mailbox would be skipped. Collect all candidates and prefer
the first with actual .emlx files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@roborev-ci
Copy link

roborev-ci bot commented Feb 26, 2026

roborev: Combined Review (6101c21)

Summary: One medium-severity issue was identified regarding Apple Mail V10 mailbox discovery prioritization.

Medium

File: internal/emlx/discover.go:198

  • Issue: findMessagesDir returns the first candidate that has at least one .emlx . If both legacy Messages/ and V10 <GUID>/Data/Messages/ are populated, legacy wins by order, which can silently import a partial/stale subset and miss newer messages in V10.
  • Suggested Fix: Choose the candidate with the highest non-partial . emlx count, or explicitly prefer V10 when both candidates are non-empty.

Synthesized from 4 reviews (agents: codex, gemini | types: default, security)

@wesm
Copy link
Owner Author

wesm commented Feb 26, 2026

"Not valid. In practice, a .mbox directory has either a legacy Messages/ or a V10 /Data/Messages/
layout — never both populated simultaneously. Apple Mail doesn't write messages to two different internal
layouts for the same mailbox. The only realistic mixed scenario is an empty stale Messages/ alongside a
populated V10 path, which the previous commit already handles.

Adding a "highest count" heuristic for a scenario that doesn't occur in real Apple Mail data would be
speculative complexity."

@wesm wesm merged commit 4801588 into main Feb 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import-emlx not importing from Apple Mail Library (~/Library/Mail)

1 participant