aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2013-01-08 23:41:54 +0200
committerGravatar David Bremner <bremner@debian.org>2013-01-09 23:08:48 -0400
commit4e9fe60422d9092737550bd8a3b8525ee2a20daf (patch)
tree055c49c39741f1137e5d6e092390ec0ac312ca25
parentff3cc5534acf6132c75f814944ca5ed300cb51c0 (diff)
cli: bail out and propagate tagging errors in notmuch tag
Checking and propagating tag_op_list_apply() errors is especially important with batch tagging, as the processing of the batch input would not stop otherwise. Additionally this sets the exit code, which is useful in scripts. Amended by: David Bremner
-rw-r--r--notmuch-tag.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 42724266..6408babb 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -97,6 +97,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
notmuch_query_t *query;
notmuch_messages_t *messages;
notmuch_message_t *message;
+ int ret = 0;
/* Optimize the query so it excludes messages that already have
* the specified set of tags. */
@@ -119,13 +120,15 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
notmuch_messages_valid (messages) && ! interrupted;
notmuch_messages_move_to_next (messages)) {
message = notmuch_messages_get (messages);
- tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);
+ ret = tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);
notmuch_message_destroy (message);
+ if (ret != NOTMUCH_STATUS_SUCCESS)
+ break;
}
notmuch_query_destroy (query);
- return interrupted;
+ return ret || interrupted;
}
static int