[PATCH v2 00/14] reply refactor, fixes
[notmuch-archives.git] / b6 / 73ec3ca3c2da2b7e6a29542dd1b1b4f3931ed5
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 C59B1429E36\r
6         for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:57 -0700 (PDT)\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 f6FsxONCc4Gh for <notmuch@notmuchmail.org>;\r
16         Thu, 17 May 2012 21:13:56 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id 3BABA431E62\r
20         for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:53 -0700 (PDT)\r
21 X-AuditID: 1209190f-b7f4f6d00000092b-3e-4fb5cc809aa4\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 18.3A.02347.08CC5BF4; Fri, 18 May 2012 00:13:52 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q4I4DpsS001785; \r
27         Fri, 18 May 2012 00:13:51 -0400\r
28 Received: from drake.mit.edu\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4I4Doal026787\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Fri, 18 May 2012 00:13:51 -0400 (EDT)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SVEZa-0000z6-Ed; Fri, 18 May 2012 00:13:50 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 4/9] lib: Make notmuch_database_get_directory return NULL if\r
41         the directory is not found\r
42 Date: Fri, 18 May 2012 00:13:37 -0400\r
43 Message-Id: <1337314423-3702-5-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
46 References: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrdtwZqu/wbp76hbXb85kdmD0eLbq\r
49         FnMAYxSXTUpqTmZZapG+XQJXxrk7KQUfJSvO7etlaWDsF+1i5OSQEDCRaOhpYYawxSQu3FvP\r
50         1sXIxSEksI9R4tT5FiYIZwOjxM6Nm5ghnPtMEguvfoUqm8Uose/nWhaQfjYBDYlt+5czgtgi\r
51         AtISO+/OZu1i5OBgFlCT+NOlAhIWFkiX+HpjIiNImEVAVeJWtzVImFfAXuLkww4WiCvkJZ7e\r
52         72MDKeEUcJCYdjwaJCwEVPLvQjPLBEb+BYwMqxhlU3KrdHMTM3OKU5N1i5MT8/JSi3RN9HIz\r
53         S/RSU0o3MYIDRpJ/B+O3g0qHGAU4GJV4eHfM2eovxJpYVlyZe4hRkoNJSZT3+0mgEF9Sfkpl\r
54         RmJxRnxRaU5q8SFGCQ5mJRFe2W6gHG9KYmVValE+TEqag0VJnFdN652fkEB6YklqdmpqQWoR\r
55         TFaGg0NJgtfiNFCjYFFqempFWmZOCUKaiYMTZDgP0HAtkBre4oLE3OLMdIj8KUZFKXFeG5CE\r
56         AEgiozQPrhcW0a8YxYFeEeYNBaniASYDuO5XQIOZgAaX5W4CGVySiJCSamBsuBLUJW3CUP1k\r
57         2YwXCWsnGqzu23f/4tmur0cO8LYuYPbI138+eRbnxhfFb5WDDr8/L/FPhF/X6OGHvJ1154xj\r
58         Zq1kf9V8ZN9R7okaqhezd0yZE/upuuuL2i5xwbz+fG3x/TdiIi/1Ol1k6vyuPrvTblVOI0/O\r
59         q52M3wr1lwsG5jwttxLKvfBKiaU4I9FQi7moOBEAuD00AcMCAAA=\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Fri, 18 May 2012 04:13:58 -0000\r
73 \r
74 Using the new support from _notmuch_directory_create, this makes\r
75 notmuch_database_get_directory a read-only operation that simply\r
76 returns the directory object if it exists or NULL otherwise.  This\r
77 also means that notmuch_database_get_directory can work on read-only\r
78 databases.\r
79 \r
80 This change breaks the directory mtime workaround in notmuch-new.c by\r
81 fixing the exact issue it was working around.  This permits mtime\r
82 update races to prevent scans of changed directories, which\r
83 non-deterministically breaks a few tests.  The next patch fixes this.\r
84 ---\r
85  lib/database.cc       |    7 ++-----\r
86  lib/notmuch-private.h |    3 +++\r
87  lib/notmuch.h         |   10 ++--------\r
88  3 files changed, 7 insertions(+), 13 deletions(-)\r
89 \r
90 diff --git a/lib/database.cc b/lib/database.cc\r
91 index b4c76b4..e27a0e1 100644\r
92 --- a/lib/database.cc\r
93 +++ b/lib/database.cc\r
94 @@ -1328,12 +1328,9 @@ notmuch_database_get_directory (notmuch_database_t *notmuch,\r
95         return NOTMUCH_STATUS_NULL_POINTER;\r
96      *directory = NULL;\r
97  \r
98 -    /* XXX Handle read-only databases properly */\r
99 -    if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)\r
100 -       return NOTMUCH_STATUS_READ_ONLY_DATABASE;\r
101 -\r
102      try {\r
103 -       *directory = _notmuch_directory_create (notmuch, path, NOTMUCH_FIND_CREATE, &status);\r
104 +       *directory = _notmuch_directory_create (notmuch, path,\r
105 +                                               NOTMUCH_FIND_LOOKUP, &status);\r
106      } catch (const Xapian::Error &error) {\r
107         fprintf (stderr, "A Xapian exception occurred getting directory: %s.\n",\r
108                  error.get_msg().c_str());\r
109 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
110 index 34f7ac7..bfb4111 100644\r
111 --- a/lib/notmuch-private.h\r
112 +++ b/lib/notmuch-private.h\r
113 @@ -148,6 +148,9 @@ typedef enum _notmuch_private_status {\r
114  \r
115  /* Flags shared by various lookup functions. */\r
116  typedef enum _notmuch_find_flags {\r
117 +    /* Lookup without creating any documents.  This is the default\r
118 +     * behavior. */\r
119 +    NOTMUCH_FIND_LOOKUP = 0,\r
120      /* If set, create the necessary document (or documents) if they\r
121       * are missing.  Requires a read/write database. */\r
122      NOTMUCH_FIND_CREATE = 1<<0,\r
123 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
124 index bbb17e4..3633bed 100644\r
125 --- a/lib/notmuch.h\r
126 +++ b/lib/notmuch.h\r
127 @@ -300,10 +300,8 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch);\r
128   * (see notmuch_database_get_path), or else should be an absolute path\r
129   * with initial components that match the path of 'database'.\r
130   *\r
131 - * Note: Currently this will create the directory object if it doesn't\r
132 - * exist.  In the future, when a directory object does not exist this\r
133 - * will return NOTMUCH_STATUS_SUCCESS and set *directory to NULL.\r
134 - * Callers should be prepared for this.\r
135 + * If this directory object does not exist in the database, this\r
136 + * returns NOTMUCH_STATUS_SUCCESS and sets *directory to NULL.\r
137   *\r
138   * Return value:\r
139   *\r
140 @@ -313,10 +311,6 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch);\r
141   *\r
142   * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred;\r
143   *     directory not retrieved.\r
144 - *\r
145 - * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only\r
146 - *     mode so the directory cannot be created (this case will be\r
147 - *     removed in the future).\r
148   */\r
149  notmuch_status_t\r
150  notmuch_database_get_directory (notmuch_database_t *database,\r
151 -- \r
152 1.7.10\r
153 \r