Skip to content

import-mbox: when re-importing duplicates, add new labels to existing messages instead of skipping #190

@endolith

Description

@endolith

When re-importing an overlapping mbox with a different --label, messages that are already in the vault are skipped and the new label is not applied. So you can’t “tag an existing import with another label” by running import again.

Request: When a message is detected as a duplicate (same source, same dedup key), still deduplicate (do not create a second message) but add the current import’s label(s) to that existing message, so it ends up with both the old and the new labels.

Use case: Import the same mailbox from different places (e.g. IMAP and a POP backup) with different labels (--label imap-inbox vs --label pop-backup). Today, the second run skips all messages and they only keep the first run’s labels. Desired: one message per logical email, with labels from all import runs (e.g. both imap-inbox and pop-backup).

Note: The emlx importer already has similar behavior: it calls AddMessageLabels when it finds an existing message (see internal/importer/emlx_import.go around the “Add labels from this mailbox to the existing message” comment). The mbox importer could do the same when it skips a message due to MessageExistsWithRawBatch / existingWithRaw: look up the existing message ID and call AddMessageLabels with the current run’s label IDs before continuing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions