The parsearchive tool can be used to load missing messages sourced
from mailman or another source. In this use case, there's a good
possibility that at least some of the messages found in the archive
are already stored in patchwork. Handle this case by ignoring these
duplicates.
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
from patchwork.bin import parsemail
+LOGGER = logging.getLogger(__name__)
+
VERBOSITY_LEVELS = {
'debug': logging.DEBUG,
'info': logging.INFO,
def parse_mbox(path, list_id):
mbox = mailbox.mbox(path)
+ duplicates = 0
for msg in mbox:
- parsemail.parse_mail(msg, list_id)
+ try:
+ parsemail.parse_mail(msg, list_id)
+ except django.db.utils.IntegrityError:
+ duplicates += 1
+ LOGGER.info('Processed %d messages, %d duplicates',
+ len(mbox), duplicates)
def main():