aboutsummaryrefslogtreecommitdiff
path: root/b4/mbox.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-12-21 13:48:51 -0500
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-12-21 13:50:58 -0500
commitab9c6a69a6bc0e1e4a5de232fee29acdaa69d2a5 (patch)
tree6527832c83491b29ccc87da812e1cd5a35658dcf /b4/mbox.py
parent10af809c0c75f6b229f72356eca07d19a4f24480 (diff)
downloadb4-ab9c6a69a6bc0e1e4a5de232fee29acdaa69d2a5.tar.gz
Add -f to "b4 mbox" to filter dupes
When saving to a maildir, add option to filter out dupes. Note, that this requires going through the entire maildir to collect message-ids, so it's not going to be a great experience on large maildirs. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/mbox.py')
-rw-r--r--b4/mbox.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/b4/mbox.py b/b4/mbox.py
index eeca363..38b2f0e 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -554,9 +554,16 @@ def main(cmdargs):
and os.path.isdir(os.path.join(cmdargs.outdir, 'cur'))
and os.path.isdir(os.path.join(cmdargs.outdir, 'tmp'))):
mdr = mailbox.Maildir(cmdargs.outdir)
+ have_msgids = set()
+ added = 0
+ if cmdargs.filterdupes:
+ for emsg in mdr:
+ have_msgids.add(b4.LoreMessage.get_clean_msgid(emsg))
for msg in mbx:
- mdr.add(msg)
- logger.info('Added to maildir %s', cmdargs.outdir)
+ if b4.LoreMessage.get_clean_msgid(msg) not in have_msgids:
+ added += 1
+ mdr.add(msg)
+ logger.info('Added to %s messages to maildir %s', added, cmdargs.outdir)
mbx.close()
os.unlink(threadfile)
return