[PATCH 2/9] lib: Perform the same transformation to _notmuch_database_find_directory_id
authorAustin Clements <amdragon@MIT.EDU>
Fri, 18 May 2012 04:13:35 +0000 (00:13 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:12 +0000 (09:47 -0800)
e5/dd619d289cccd814a20d2c09329211875966a0 [new file with mode: 0644]

diff --git a/e5/dd619d289cccd814a20d2c09329211875966a0 b/e5/dd619d289cccd814a20d2c09329211875966a0
new file mode 100644 (file)
index 0000000..35c8060
--- /dev/null
@@ -0,0 +1,159 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id E2D6B431FC2\r
+       for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:55 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id iWrpJCR5tF2x for <notmuch@notmuchmail.org>;\r
+       Thu, 17 May 2012 21:13:54 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+       [18.9.25.15])\r
+       by olra.theworths.org (Postfix) with ESMTP id EE18D431FD5\r
+       for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:52 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f4f6d00000092b-3d-4fb5cc8049b9\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id E7.3A.02347.08CC5BF4; Fri, 18 May 2012 00:13:52 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q4I4Dpdn021450; \r
+       Fri, 18 May 2012 00:13:51 -0400\r
+Received: from drake.mit.edu\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4I4DoEY026783\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 18 May 2012 00:13:51 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SVEZZ-0000z0-Uw; Fri, 18 May 2012 00:13:50 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/9] lib: Perform the same transformation to\r
+       _notmuch_database_find_directory_id\r
+Date: Fri, 18 May 2012 00:13:35 -0400\r
+Message-Id: <1337314423-3702-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
+References: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nottwZqu/wYsPEhbXb85kdmD0eLbq\r
+       FnMAYxSXTUpqTmZZapG+XQJXxqVLdxgLJklUbL/2gbWBcYtwFyMnh4SAicT7PT3MELaYxIV7\r
+       69lAbCGBfYwSE19qdzFyAdkbGCVuXlrNAuHcZ5LoPf6XGcKZxSjx8cB1RpAWNgENiW37l4PZ\r
+       IgLSEjvvzmbtYuTgYBZQk/jTpQISFhZIkDi7dDkriM0ioCrx/M8OsM28AvYS329OZIW4Ql7i\r
+       6f0+NpBWTgEHiWnHoyEOspf4d6GZZQIj/wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW6Jnq5\r
+       mSV6qSmlmxhBIcMpyb+D8dtBpUOMAhyMSjy8O+Zs9RdiTSwrrsw9xCjJwaQkyvv9JFCILyk/\r
+       pTIjsTgjvqg0J7X4EKMEB7OSCK9sN1CONyWxsiq1KB8mJc3BoiTOq6b1zk9IID2xJDU7NbUg\r
+       tQgmK8PBoSTBa3EaqFGwKDU9tSItM6cEIc3EwQkynAdouBZIDW9xQWJucWY6RP4Uo6KUOK8N\r
+       SEIAJJFRmgfXC4vpV4ziQK8I84aCVPEA0wFc9yugwUxAg8tyN4EMLklESEk1MIa91Jpfs43t\r
+       dmvQg18tvHNFA0z4Wz6vlk45NGnNqoDNoaGaTuZpQavd9sgwXuYQOfhneqv0y9bZ1x7LvPNr\r
+       mmqS8M3kdt2Zp/rbG/5ZTj11MdN3n+H9i647hWpyhXWXNxTsEPa+2x30Zus9pXbTWcX1j973\r
+       23ld85Lmzb7atuNEZPNyy/vzRJRYijMSDbWYi4oTAUeKw4bEAgAA\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 18 May 2012 04:13:56 -0000\r
+\r
+Now _notmuch_database_find_directory_id takes a flags argument, which\r
+it passes through to _notmuch_directory_create and can indicate if the\r
+directory does not exist.  Again, callers have been updated, but\r
+retain their original behavior.\r
+---\r
+ lib/database.cc       |   14 +++++++++++---\r
+ lib/directory.cc      |    8 +++++++-\r
+ lib/notmuch-private.h |    1 +\r
+ 3 files changed, 19 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index df996a9..716982d 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1197,9 +1197,17 @@ _notmuch_database_split_path (void *ctx,\r
+     return NOTMUCH_STATUS_SUCCESS;\r
+ }\r
\r
++/* Find the document ID of the specified directory.\r
++ *\r
++ * If (flags & NOTMUCH_FIND_CREATE), a new directory document will be\r
++ * created if one does not exist for 'path'.  Otherwise, if the\r
++ * directory document does not exist, this sets *directory_id to\r
++ * ((unsigned int)-1) and returns NOTMUCH_STATUS_SUCCESS.\r
++ */\r
+ notmuch_status_t\r
+ _notmuch_database_find_directory_id (notmuch_database_t *notmuch,\r
+                                    const char *path,\r
++                                   notmuch_find_flags_t flags,\r
+                                    unsigned int *directory_id)\r
+ {\r
+     notmuch_directory_t *directory;\r
+@@ -1210,8 +1218,8 @@ _notmuch_database_find_directory_id (notmuch_database_t *notmuch,\r
+       return NOTMUCH_STATUS_SUCCESS;\r
+     }\r
\r
+-    directory = _notmuch_directory_create (notmuch, path, NOTMUCH_FIND_CREATE, &status);\r
+-    if (status) {\r
++    directory = _notmuch_directory_create (notmuch, path, flags, &status);\r
++    if (status || !directory) {\r
+       *directory_id = -1;\r
+       return status;\r
+     }\r
+@@ -1260,7 +1268,7 @@ _notmuch_database_filename_to_direntry (void *ctx,\r
+     if (status)\r
+       return status;\r
\r
+-    status = _notmuch_database_find_directory_id (notmuch, directory,\r
++    status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE,\r
+                                                 &directory_id);\r
+     if (status)\r
+       return status;\r
+diff --git a/lib/directory.cc b/lib/directory.cc\r
+index 83bb19b..6a3ffed 100644\r
+--- a/lib/directory.cc\r
++++ b/lib/directory.cc\r
+@@ -153,7 +153,13 @@ _notmuch_directory_create (notmuch_database_t *notmuch,\r
\r
+           _notmuch_database_split_path (local, path, &parent, &basename);\r
\r
+-          _notmuch_database_find_directory_id (notmuch, parent, &parent_id);\r
++          *status_ret = _notmuch_database_find_directory_id (\r
++              notmuch, parent, NOTMUCH_FIND_CREATE, &parent_id);\r
++          if (*status_ret) {\r
++              notmuch_directory_destroy (directory);\r
++              directory = NULL;\r
++              goto DONE;\r
++          }\r
\r
+           if (basename) {\r
+               term = talloc_asprintf (local, "%s%u:%s",\r
+diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+index 538274f..a36549d 100644\r
+--- a/lib/notmuch-private.h\r
++++ b/lib/notmuch-private.h\r
+@@ -195,6 +195,7 @@ _notmuch_database_find_unique_doc_id (notmuch_database_t *notmuch,\r
+ notmuch_status_t\r
+ _notmuch_database_find_directory_id (notmuch_database_t *database,\r
+                                    const char *path,\r
++                                   notmuch_find_flags_t flags,\r
+                                    unsigned int *directory_id);\r
\r
+ const char *\r
+-- \r
+1.7.10\r
+\r