[PATCH] notmuch.Database.remove_message should raise exception on failure
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Wed, 10 Feb 2016 16:53:46 +0000 (11:53 +1900)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:05 +0000 (16:21 -0700)
0f/ad8e7caa7d14e3c70b5b18fb4efc72a2760926 [new file with mode: 0644]

diff --git a/0f/ad8e7caa7d14e3c70b5b18fb4efc72a2760926 b/0f/ad8e7caa7d14e3c70b5b18fb4efc72a2760926
new file mode 100644 (file)
index 0000000..63914eb
--- /dev/null
@@ -0,0 +1,71 @@
+Return-Path: <dkg@fifthhorseman.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id C09AE6DE179D\r
+ for <notmuch@notmuchmail.org>; Wed, 10 Feb 2016 08:53:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.017\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.017 tagged_above=-999 required=5\r
+ tests=[AWL=-0.017] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id dAiq4Yz8x_3N for <notmuch@notmuchmail.org>;\r
+ Wed, 10 Feb 2016 08:53:51 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 27E436DE0FF8\r
+ for <notmuch@notmuchmail.org>; Wed, 10 Feb 2016 08:53:51 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id E15F1F997\r
+ for <notmuch@notmuchmail.org>; Wed, 10 Feb 2016 11:53:46 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 00C0B200C1; Wed, 10 Feb 2016 11:53:46 -0500 (EST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH] notmuch.Database.remove_message should raise exception on\r
+ failure\r
+Date: Wed, 10 Feb 2016 11:53:46 -0500\r
+Message-Id: <1455123226-1929-1-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.7.0\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 10 Feb 2016 16:53:52 -0000\r
+\r
+The notmuch python bindings document that database.remove_message\r
+should raise an exception when the message removal fails, but they\r
+don't actually do it.\r
+---\r
+ bindings/python/notmuch/database.py | 5 ++++-\r
+ 1 file changed, 4 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 93e7b7a..f304533 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\r
+@@ -483,7 +483,10 @@ class Database(object):\r
+                removed.\r
+         """\r
+         self._assert_db_is_initialized()\r
+-        return self._remove_message(self._db, _str(filename))\r
++        status = self._remove_message(self._db, _str(filename))\r
++        if status not in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:\r
++            raise NotmuchError(status)\r
++        return status\r
\r
+     def find_message(self, msgid):\r
+         """Returns a :class:`Message` as identified by its message ID\r
+-- \r
+2.7.0\r
+\r