[PATCH 1/3] cli: Return an error code from add_message_to_database

Subject: [PATCH 1/3] cli: Return an error code from add_message_to_database

Date: Sat, 13 Jul 2013 18:45:44 -0600

To: notmuch@notmuchmail.org

Cc:

From: Adam Wolfe Gordon


The error code isn't necessary when we're inserting a new message from
standard input, but it will be useful for an upcoming command that
allows an existing file to be indexed.
---
 notmuch-insert.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 2207b1e..d32a535 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -293,7 +293,7 @@ copy_stdin (int fdin, int fdout)
 
 /* Add the specified message file to the notmuch database, applying tags.
  * The file is renamed to encode notmuch tags as maildir flags. */
-static void
+static int
 add_file_to_database (notmuch_database_t *notmuch, const char *path,
 		      tag_op_list_t *tag_ops)
 {
@@ -318,7 +318,7 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
     case NOTMUCH_STATUS_LAST_STATUS:
 	fprintf (stderr, "Error: failed to add `%s' to notmuch database: %s\n",
 		 path, notmuch_status_to_string (status));
-	return;
+	return status;
     }
 
     if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
@@ -331,6 +331,8 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,
     }
 
     notmuch_message_destroy (message);
+
+    return status;
 }
 
 static notmuch_bool_t
@@ -377,7 +379,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
 
     /* Even if adding the message to the notmuch database fails,
      * the message is on disk and we consider the delivery completed. */
-    add_file_to_database (notmuch, newpath, tag_ops);
+    (void) add_file_to_database (notmuch, newpath, tag_ops);
 
     return TRUE;
 
-- 
1.7.9.5


Thread: