[PATCH 1/3] Use the Xapian::DB_RETRY_LOCK flag when available
[notmuch-archives.git] / cb / b9256ea9701a1798247ecf05de1ca6fbf8df1b
1 Return-Path: <zack@upsilon.cc>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 184C3431FC9\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Feb 2015 01:41:47 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.338\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.338 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id KdBz1qqFDXv1 for <notmuch@notmuchmail.org>;\r
17         Mon,  9 Feb 2015 01:41:43 -0800 (PST)\r
18 Received: from upsilon.cc (upsilon.cc [178.32.142.91])\r
19         by olra.theworths.org (Postfix) with ESMTP id 01A98431FCF\r
20         for <notmuch@notmuchmail.org>; Mon,  9 Feb 2015 01:41:42 -0800 (PST)\r
21 Received: from timira.takhisis.invalid (maths.r-prg.net.univ-paris7.fr\r
22         [81.194.27.158]) by upsilon.cc (Postfix) with ESMTPSA id 3027710E51;\r
23         Mon,  9 Feb 2015 10:41:42 +0100 (CET)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upsilon.cc; s=mail;\r
25         t=1423474902; bh=RgHHPbGpmwrC43KVLpMI0KL6u7qnoOE81WWVapPJEks=;\r
26         h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\r
27         b=hD9Mm3RoW2N9HRoSUxzajfz4DA1odJMp4dkx37MqniN0N6CdL36P0NfcFAthJ7By8\r
28         hU7pttveu4lZK7/jcyKt8wURYBuWUcY7xtamJhEAFxO4tZtdsytsgsgOlTx74HxEDX\r
29         pmEhk3TntLM6ymfDLRSIykSZy6JoXWHOq8Qv9/iQ=\r
30 Received: by timira.takhisis.invalid (Postfix, from userid 1000)\r
31         id BA0A9600E1; Mon,  9 Feb 2015 10:41:41 +0100 (CET)\r
32 From: Stefano Zacchiroli <zack@upsilon.cc>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [PATCH 2/2] notmuch-mutt: support for messages that lack Message-ID\r
35         headers\r
36 Date: Mon,  9 Feb 2015 10:41:30 +0100\r
37 Message-Id: <1423474890-16972-3-git-send-email-zack@upsilon.cc>\r
38 X-Mailer: git-send-email 2.1.4\r
39 In-Reply-To: <1423474890-16972-1-git-send-email-zack@upsilon.cc>\r
40 References: <1423474890-16972-1-git-send-email-zack@upsilon.cc>\r
41 Cc: zack@upsilon.cc\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Mon, 09 Feb 2015 09:41:47 -0000\r
55 \r
56 From: "Jan N. Klug" <jan.n.klug@rub.de>\r
57 \r
58 For those messages, compute a synthetic Message-ID based on the SHA1\r
59 of the whole message, in the same way that notmuch would do. See:\r
60 http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c\r
61 \r
62 To do the above, rewrite get_message_id() to scan the current message\r
63 line by line, incrementally computing a SHA1. If a Message-ID is found\r
64 the SHA1 computation will be aborted; otherwise used for the synthetic\r
65 Message-ID.\r
66 \r
67 Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>\r
68 ---\r
69  contrib/notmuch-mutt/README       |  4 +++-\r
70  contrib/notmuch-mutt/notmuch-mutt | 33 ++++++++++++++++++++++++++++-----\r
71  2 files changed, 31 insertions(+), 6 deletions(-)\r
72 \r
73 diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README\r
74 index c661447..9c3379e 100644\r
75 --- a/contrib/notmuch-mutt/README\r
76 +++ b/contrib/notmuch-mutt/README\r
77 @@ -33,9 +33,11 @@ Requirements\r
78  \r
79  To *run* notmuch-mutt you will need Perl with the following libraries:\r
80  \r
81 +- Digest::SHA <https://metacpan.org/release/Digest-SHA>\r
82 +  (Debian package: libdigest-sha-perl)\r
83  - Mail::Box <https://metacpan.org/pod/Mail::Box>\r
84    (Debian package: libmail-box-perl)\r
85 -- Mail::Internet <https://metacpan.org/pod/Mail::Internet>\r
86 +- Mail::Header <https://metacpan.org/pod/Mail::Header>\r
87    (Debian package: libmailtools-perl)\r
88  - String::ShellQuote <https://metacpan.org/pod/String::ShellQuote>\r
89    (Debian package: libstring-shellquote-perl)\r
90 diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt\r
91 index 4969e4b..84af140 100755\r
92 --- a/contrib/notmuch-mutt/notmuch-mutt\r
93 +++ b/contrib/notmuch-mutt/notmuch-mutt\r
94 @@ -13,11 +13,12 @@ use warnings;\r
95  \r
96  use File::Path;\r
97  use Getopt::Long qw(:config no_getopt_compat);\r
98 -use Mail::Internet;\r
99 +use Mail::Header;\r
100  use Mail::Box::Maildir;\r
101  use Pod::Usage;\r
102  use String::ShellQuote;\r
103  use Term::ReadLine;\r
104 +use Digest::SHA;\r
105  \r
106  \r
107  my $xdg_cache_dir = "$ENV{HOME}/.cache";\r
108 @@ -75,10 +76,32 @@ sub prompt($$) {\r
109  }\r
110  \r
111  sub get_message_id() {\r
112 -    my $mail = Mail::Internet->new(\*STDIN);\r
113 -    my $mid = $mail->head->get("message-id") or return undef;\r
114 -    $mid =~ /^<(.*)>$/;        # get message-id value\r
115 -    return $1;\r
116 +    my $mid = undef;\r
117 +    my $in_header = 1;\r
118 +    my @raw_header = ();\r
119 +    my $sha = Digest::SHA->new(1);  # SHA1 hash of the whole mail\r
120 +\r
121 +    while (<STDIN>) {  # compute SHA1 as we go\r
122 +       push(@raw_header, $_) if $in_header;  # cache header lines\r
123 +        if ($_ =~ /^$/) {  # end of header, parse it and look for Message-ID\r
124 +           $in_header = 0;\r
125 +           my $head = Mail::Header->new(\@raw_header);\r
126 +           $mid = $head->get("message-id") or undef;\r
127 +           if ($mid) {\r
128 +               $mid =~ /^<(.*)>$/;  # get message-id value\r
129 +               $mid = $1;\r
130 +               last;  # stop hashing\r
131 +           }\r
132 +        }\r
133 +       $sha->add($_);  # update hash\r
134 +    }\r
135 +\r
136 +    # If no message-id was found, generate one-id in the same way that\r
137 +    # notmuch would do.\r
138 +    # See: http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c\r
139 +    $mid ||= "notmuch-sha1-".$sha->hexdigest;\r
140 +\r
141 +    return $mid;\r
142  }\r
143  \r
144  sub search_action($$$@) {\r
145 -- \r
146 2.1.4\r
147 \r