[PATCH v2 3/5] python: Update for changes to notmuch_database_get_directory
authorAustin Clements <amdragon@MIT.EDU>
Sun, 13 May 2012 23:36:11 +0000 (19:36 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:05 +0000 (09:47 -0800)
af/ace3961e36dd9e54089500e0edbca4d8d3329e [new file with mode: 0644]

diff --git a/af/ace3961e36dd9e54089500e0edbca4d8d3329e b/af/ace3961e36dd9e54089500e0edbca4d8d3329e
new file mode 100644 (file)
index 0000000..5a1ac94
--- /dev/null
@@ -0,0 +1,130 @@
+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 24337431FD2\r
+       for <notmuch@notmuchmail.org>; Sun, 13 May 2012 16:36:27 -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 loPIorvo0PyR for <notmuch@notmuchmail.org>;\r
+       Sun, 13 May 2012 16:36:25 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
+       [18.7.68.35])\r
+       by olra.theworths.org (Postfix) with ESMTP id EC220431FBF\r
+       for <notmuch@notmuchmail.org>; Sun, 13 May 2012 16:36:23 -0700 (PDT)\r
+X-AuditID: 12074423-b7fcc6d0000008a8-da-4fb0457774f6\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id EE.F8.02216.77540BF4; Sun, 13 May 2012 19:36:23 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q4DNaLRW009043; \r
+       Sun, 13 May 2012 19:36:22 -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 q4DNaKmL001098\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sun, 13 May 2012 19:36:21 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1STiKq-0004YP-4d; Sun, 13 May 2012 19:36:20 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/5] python: Update for changes to\r
+       notmuch_database_get_directory\r
+Date: Sun, 13 May 2012 19:36:11 -0400\r
+Message-Id: <1336952173-17422-4-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1336952173-17422-1-git-send-email-amdragon@mit.edu>\r
+References: <1336939029-13969-1-git-send-email-amdragon@mit.edu>\r
+       <1336952173-17422-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsUixG6nrlvuusHfYNIzPYvZrT+YLG60djNa\r
+       NE13trh+cyazxZuV81gdWD0Of13I4jHx/Gk2j1v3X7N7PFt1i9ljy6H3zAGsUVw2Kak5mWWp\r
+       Rfp2CVwZs6dvZym4JVjRfHQucwPjbt4uRk4OCQETiW19N9ghbDGJC/fWs3UxcnEICexjlPi1\r
+       4A4ThLOBUWLn6jZGCOc+k8T97u2sEM4sRol9nb9ZQPrZBDQktu1fzghiiwhIS+y8OxusiFmg\r
+       i1Hi95tmZpCEsECIRNOpE2wgNouAqsTdXfPAbF4BB4l7PzoZIQ6Rl3h6vw8szingKNH34CPY\r
+       gUIC5RIz2q+zTGDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyM4EF2U\r
+       dzD+Oah0iFGAg1GJh/el6QZ/IdbEsuLK3EOMkhxMSqK8TE5AIb6k/JTKjMTijPii0pzU4kOM\r
+       EhzMSiK86x+u9xfiTUmsrEotyodJSXOwKInzami98xMSSE8sSc1OTS1ILYLJynBwKEnwLnYB\r
+       GipYlJqeWpGWmVOCkGbi4AQZzgM0/AxIDW9xQWJucWY6RP4Uoy7Hn4eLrjEKseTl56VKifPO\r
+       ACkSACnKKM2DmwNLIK8YxYHeEubdC1LFA0w+cJNeAS1hAlrCL7AOZElJIkJKqoGxLrbt74WJ\r
+       s5IevfaQW6iksoyrSuNQr6S89IHXDfqCE+aZ1v1oOfDI8WyN6aGlkf8jb87yfGpjYvWvg/nZ\r
+       FIn/bu0TP76KZV+lWhuea1KgPNPkYnCeW2z3zSUff6WuTFGcGh17f8a6F5fqbL13fF9WPWHZ\r
+       FAb/Z78OJW04Lu1n9uuURaaR6+leJZbijERDLeai4kQA3EUqCfsCAAA=\r
+Cc: tomi.ollila@iki.fi\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: Sun, 13 May 2012 23:36:27 -0000\r
+\r
+notmuch_database_get_directory now returns\r
+NOTMUCH_STATUS_READ_ONLY_DATABASE on its own (rather than crashing) so\r
+the workaround in Database.get_directory is no longer necessary.\r
+---\r
+ bindings/python/notmuch/database.py |   19 +++++++++----------\r
+ 1 file changed, 9 insertions(+), 10 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 1b1ddc3..797554d 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\r
+@@ -73,8 +73,8 @@ class Database(object):\r
+ \r
+     """notmuch_database_get_directory"""\r
+     _get_directory = nmlib.notmuch_database_get_directory\r
+-    _get_directory.argtypes = [NotmuchDatabaseP, c_char_p]\r
+-    _get_directory.restype = NotmuchDirectoryP\r
++    _get_directory.argtypes = [NotmuchDatabaseP, c_char_p, POINTER(NotmuchDirectoryP)]\r
++    _get_directory.restype = c_uint\r
+ \r
+     """notmuch_database_get_path"""\r
+     _get_path = nmlib.notmuch_database_get_path\r
+@@ -359,13 +359,6 @@ class Database(object):\r
+         """\r
+         self._assert_db_is_initialized()\r
+ \r
+-        # work around libnotmuch calling exit(3), see\r
+-        # id:20120221002921.8534.57091@thinkbox.jade-hamburg.de\r
+-        # TODO: remove once this issue is resolved\r
+-        if self.mode != Database.MODE.READ_WRITE:\r
+-            raise ReadOnlyDatabaseError('The database has to be opened in '\r
+-                                        'read-write mode for get_directory')\r
+-\r
+         # sanity checking if path is valid, and make path absolute\r
+         if path and path[0] == os.sep:\r
+             # we got an absolute path\r
+@@ -378,7 +371,13 @@ class Database(object):\r
+             #we got a relative path, make it absolute\r
+             abs_dirpath = os.path.abspath(os.path.join(self.get_path(), path))\r
+ \r
+-        dir_p = Database._get_directory(self._db, _str(path))\r
++        dir_p = NotmuchDirectoryP()\r
++        status = Database._get_directory(self._db, _str(path), byref(dir_p))\r
++\r
++        if status != STATUS.SUCCESS:\r
++            raise NotmuchError(status)\r
++        if not dir_p:\r
++            return None\r
+ \r
+         # return the Directory, init it with the absolute path\r
+         return Directory(abs_dirpath, dir_p, self)\r
+-- \r
+1.7.10\r
+\r