Re: Hi all
[notmuch-archives.git] / 89 / 85c94cda83099d98d6b089f5daf3538554c83b
1 Return-Path: <amdragon@mit.edu>\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 01BC6431FAF\r
6         for <notmuch@notmuchmail.org>; Thu,  6 Mar 2014 13:06:33 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 91RJWhfdfZhp for <notmuch@notmuchmail.org>;\r
16         Thu,  6 Mar 2014 13:06:27 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 61B75431FAE\r
22         for <notmuch@notmuchmail.org>; Thu,  6 Mar 2014 13:06:27 -0800 (PST)\r
23 X-AuditID: 12074424-f79e26d000000c70-a7-5318e352716d\r
24 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 45.0F.03184.253E8135; Thu,  6 Mar 2014 16:06:26 -0500 (EST)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s26L6PxD009277; \r
31         Thu, 6 Mar 2014 16:06:26 -0500\r
32 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
33         (authenticated bits=0)\r
34         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
35         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s26L6MmV024989\r
36         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
37         Thu, 6 Mar 2014 16:06:24 -0500\r
38 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
39         (envelope-from <amdragon@mit.edu>)\r
40         id 1WLfUk-0003PV-Ox; Thu, 06 Mar 2014 16:06:22 -0500\r
41 Date: Thu, 6 Mar 2014 16:06:22 -0500\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: Mark Walters <markwalters1009@gmail.com>\r
44 Subject: Re: [PATCH] notmuch new: add a --in-directory option\r
45 Message-ID: <20140306210622.GI4709@mit.edu>\r
46 References: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 Content-Disposition: inline\r
50 In-Reply-To: <1394139507-15324-1-git-send-email-markwalters1009@gmail.com>\r
51 User-Agent: Mutt/1.5.21 (2010-09-15)\r
52 X-Brightmail-Tracker:\r
53  H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1w16LBFs0P9GyWL1XB6L6zdnMjsw\r
54         eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGR/6VjEXfBGvWHp2GlMDY4dwFyMnh4SAicTF\r
55         Q+tZIWwxiQv31rN1MXJxCAnMZpLYuO8XK4SzgVHi4PW1TBDOKSaJ/51boDJLGCUOb93ECNLP\r
56         IqAisfDoTrBZbAIaEtv2LweLiwjoSNw+tIAdxGYWkJb49ruZCcQWFrCV+P3gM1icV0BbYu31\r
57         XSwgtpCAp8Sxw/eZIOKCEidnPmGB6NWSuPHvJVCcA2zO8n8cIGFOAS+JX49OgpWLAp0w5eQ2\r
58         tgmMQrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXXO93MwSvdSU0k2M4LB2\r
59         UdnB2HxI6RCjAAejEg9vxyKJYCHWxLLiytxDjJIcTEqivO4PgEJ8SfkplRmJxRnxRaU5qcWH\r
60         GCU4mJVEeI0PAuV4UxIrq1KL8mFS0hwsSuK8fWeBUgLpiSWp2ampBalFMFkZDg4lCV6zR0BZ\r
61         waLU9NSKtMycEoQ0EwcnyHAeoOFaIDW8xQWJucWZ6RD5U4yKUuK8viAJAZBERmkeXC8s7bxi\r
62         FAd6RZi3DKSKB5iy4LpfAQ1mAhoczScOMrgkESEl1cCY0lcotKg5Z+fqsNRXBgyPlC9Vz3qV\r
63         VnCqPethuGipu+ay4uJnzRKpyyaUByT/r5Bt3lH7/+Y22TcJFmclyqZ1Xr69fk4rf1x4QwY3\r
64         a7VYl9feZUZR3U/zFp5O7P32vJmxc9rJVfUH3n9+7Pk3fcrXpUfLt3zZYvb8vV+xgMP1kM+a\r
65         z6vZPb8osRRnJBpqMRcVJwIAfC45tRYDAAA=\r
66 Cc: notmuch@notmuchmail.org\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.13\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71         <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
78         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Thu, 06 Mar 2014 21:06:34 -0000\r
80 \r
81 I haven't thought about this as a patch yet, but wanted to point out\r
82 that it should probably skip the removal step if it's only scanning a\r
83 subdirectory.  Otherwise, messages that are moved out of the scanned\r
84 directory into some other may be considered deleted and get removed\r
85 from the database.\r
86 \r
87 That aside, I'm curious what the use case for this is.\r
88 \r
89 Quoth Mark Walters on Mar 06 at  8:58 pm:\r
90 > This patch adds a --in-directory=folder option to notmuch new which\r
91 > tells it to only check for new messages inside folder (relative to the\r
92 > database root)\r
93 > ---\r
94\r
95 > NOTE This is only very lightly tested (but seems to work) so please\r
96 > make sure you backup the notmuch database before testing!\r
97\r
98\r
99 >  notmuch-new.c    |   10 +++++++++-\r
100 >  test/T050-new.sh |   15 +++++++++++++++\r
101 >  2 files changed, 24 insertions(+), 1 deletions(-)\r
102\r
103 > diff --git a/notmuch-new.c b/notmuch-new.c\r
104 > index 8529fdd..d3526ac 100644\r
105 > --- a/notmuch-new.c\r
106 > +++ b/notmuch-new.c\r
107 > @@ -922,6 +922,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
108 >      notmuch_bool_t timer_is_active = FALSE;\r
109 >      notmuch_bool_t no_hooks = FALSE;\r
110 >      notmuch_bool_t quiet = FALSE, verbose = FALSE;\r
111 > +    char *directory = NULL;\r
112 > +    char *path = NULL;\r
113 >  \r
114 >      add_files_state.verbosity = VERBOSITY_NORMAL;\r
115 >      add_files_state.debug = FALSE;\r
116 > @@ -932,6 +934,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
117 >       { NOTMUCH_OPT_BOOLEAN,  &verbose, "verbose", 'v', 0 },\r
118 >       { NOTMUCH_OPT_BOOLEAN,  &add_files_state.debug, "debug", 'd', 0 },\r
119 >       { NOTMUCH_OPT_BOOLEAN,  &no_hooks, "no-hooks", 'n', 0 },\r
120 > +     { NOTMUCH_OPT_STRING, &directory, "in-directory", 'i', 0  },\r
121 >       { 0, 0, 0, 0, 0 }\r
122 >      };\r
123 >  \r
124 > @@ -1021,7 +1024,12 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
125 >       timer_is_active = TRUE;\r
126 >      }\r
127 >  \r
128 > -    ret = add_files (notmuch, db_path, &add_files_state);\r
129 > +    if (directory)\r
130 > +     path = talloc_asprintf (config, "%s/%s", db_path, directory);\r
131 > +    else\r
132 > +     path = talloc_strdup (config, db_path);\r
133 > +\r
134 > +    ret = add_files (notmuch, path, &add_files_state);\r
135 >      if (ret)\r
136 >       goto DONE;\r
137 >  \r
138 > diff --git a/test/T050-new.sh b/test/T050-new.sh\r
139 > index b7668ff..b8e68a3 100755\r
140 > --- a/test/T050-new.sh\r
141 > +++ b/test/T050-new.sh\r
142 > @@ -263,4 +263,19 @@ notmuch search --format=text0 --output=files --offset=1 --limit=1 '*' | xargs -0\r
143 >  output=$(NOTMUCH_NEW --quiet)\r
144 >  test_expect_equal "$output" ""\r
145 >  \r
146 > +test_begin_subtest "In-directory"\r
147 > +rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch\r
148 > +mkdir "${MAIL_DIR}"/def\r
149 > +mkdir "${MAIL_DIR}"/ghi\r
150 > +generate_message [dir]=def\r
151 > +generate_message [dir]=ghi\r
152 > +generate_message\r
153 > +\r
154 > +output=$(NOTMUCH_NEW --in-directory=def)\r
155 > +test_expect_equal "$output" "Added 1 new message to the database."\r
156 > +\r
157 > +test_begin_subtest "New after --in-directory"\r
158 > +output=$(NOTMUCH_NEW)\r
159 > +test_expect_equal "$output" "Added 2 new messages to the database."\r
160 > +\r
161 >  test_done\r