From 20722ba22162d1ddeae3615b3010b8311dd9cf42 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 30 Nov 2020 17:39:52 -0500 Subject: If using -m, reduce local mbox to strict thread When passing a local mbox, don't assume that it is going to contain a strict thread already -- it can be just a local mailbox via something like mbsync. This grabs actual thread from the mailbox before looking at individual messages. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 2 +- b4/mbox.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 5c59150..07f2aad 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2206,7 +2206,7 @@ def save_strict_thread(in_mbx, out_mbx, msgid): return None if len(in_mbx) > len(out_mbx): - logger.info('Reduced thread to strict matches only (%s->%s)', len(in_mbx), len(out_mbx)) + logger.debug('Reduced mbox to strict matches only (%s->%s)', len(in_mbx), len(out_mbx)) def get_pi_thread_by_url(t_mbx_url, savefile, nocache=False): diff --git a/b4/mbox.py b/b4/mbox.py index f34b887..e9a2ab2 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -511,7 +511,14 @@ def main(cmdargs): return else: if os.path.exists(cmdargs.localmbox): - threadmbox = cmdargs.localmbox + msgid = b4.get_msgid(cmdargs) + if os.path.isdir(cmdargs.localmbox): + in_mbx = mailbox.Maildir(cmdargs.localmbox) + else: + in_mbx = mailbox.mbox(cmdargs.localmbox) + out_mbx = mailbox.mbox(savefile) + b4.save_strict_thread(in_mbx, out_mbx, msgid) + threadmbox = savefile else: logger.critical('Mailbox %s does not exist', cmdargs.localmbox) os.unlink(savefile) -- cgit v1.2.3