[PATCH 3/5] python: Update for changes to notmuch_database_get_directory
authorAustin Clements <amdragon@MIT.EDU>
Sun, 13 May 2012 19:57:07 +0000 (15:57 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:04 +0000 (09:47 -0800)
53/46907abd09af61f0720fcfcddc1847535bdd61 [new file with mode: 0644]

diff --git a/53/46907abd09af61f0720fcfcddc1847535bdd61 b/53/46907abd09af61f0720fcfcddc1847535bdd61
new file mode 100644 (file)
index 0000000..86ed552
--- /dev/null
@@ -0,0 +1,118 @@
+Return-Path: <amthrax@drake.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 0A21E431FDA\r
+       for <notmuch@notmuchmail.org>; Sun, 13 May 2012 12:57: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 FVJKz5xQqmHX for <notmuch@notmuchmail.org>;\r
+       Sun, 13 May 2012 12:57:24 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 92333431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 13 May 2012 12:57:23 -0700 (PDT)\r
+X-AuditID: 1209190e-b7fd86d0000008b4-22-4fb01222f4f7\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id CA.0C.02228.22210BF4; Sun, 13 May 2012 15:57:22 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q4DJvK2w015079; \r
+       Sun, 13 May 2012 15:57:20 -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 q4DJvGoE022910\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sun, 13 May 2012 15:57:16 -0400 (EDT)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amthrax@drake.mit.edu>)\r
+       id 1STeup-0003et-Tp; Sun, 13 May 2012 15:57:15 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/5] python: Update for changes to\r
+       notmuch_database_get_directory\r
+Date: Sun, 13 May 2012 15:57:07 -0400\r
+Message-Id: <1336939029-13969-4-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1336939029-13969-1-git-send-email-amdragon@mit.edu>\r
+References: <1336939029-13969-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsUixCmqrasktMHfYMJ9AYvZrT+YLG60djNa\r
+       NE13trh+cyazxZuV81gdWD0Of13I4jHx/Gk2j1v3X7N7PFt1i9ljy6H3zAGsUVw2Kak5mWWp\r
+       Rfp2CVwZX5+XF/zgrXi4/iV7A+NKri5GDg4JAROJ340CXYycQKaYxIV769m6GLk4hAT2MUoc\r
+       637DCuFsYJRo2buSHcK5zyTxvWcPVGY+o8TL/r2MIP1sAhoS2/YvB7NFBKQldt6dDVbEDDRd\r
+       4vebZmaQhLBAoMSbP81MILtZBFQlFj30AAnzCjhI/O5bxAxxh7zE0/t9bCA2p4CjxLIrC8Hi\r
+       QkA1Jz/+ZZ7AyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrrFebmaJXmpK6SZGcAhK8u1g\r
+       /HpQ6RCjAAejEg/vAtH1/kKsiWXFlbmHGCU5mJREedMEN/gL8SXlp1RmJBZnxBeV5qQWH2KU\r
+       4GBWEuFd/xConDclsbIqtSgfJiXNwaIkzqum9c5PSCA9sSQ1OzW1ILUIJivDwaEkwWsIMlSw\r
+       KDU9tSItM6cEIc3EwQkynAdoeApIDW9xQWJucWY6RP4Uoy7Hn4eLrjEKseTl56VKifMagBQJ\r
+       gBRllObBzYGljleM4kBvCfPuBaniAaYduEmvgJYwAS3hF1gHsqQkESEl1cAoq5L1fUfBpoSf\r
+       du5lbqF9uSK3r19lOPfCWOi81JXttxg0LvEv8N507KOJa0TkWeYr7KdaHXawRN+RdH7FnWKq\r
+       piDRzD/BVijC4FSnxzWRQ3esRJUfex+a1T9vwhuH0uwVwq26z0w0Wm04q3ZvqO1fuC8nnzOh\r
+       lc+sbRPnqdTMJ7L5Et/avyixFGckGmoxFxUnAgDNPhzP+AIAAA==\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 19:57: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 |   15 +++++++--------\r
+ 1 file changed, 7 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 0a58dd0..797554d 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\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