dovecot-2.2: doveadm: If search query attempts to access nonexis...

dovecot at dovecot.org dovecot at dovecot.org
Mon May 6 17:30:17 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/63555663efbc
changeset: 16333:63555663efbc
user:      Timo Sirainen <tss at iki.fi>
date:      Mon May 06 17:30:07 2013 +0300
description:
doveadm: If search query attempts to access nonexistent mailbox, just ignore it.
Most importantly running a query for multiple users wouldn't be an error if
the mailbox existed only for some users. It's probably cleaner to then
always just ignore the nonexistent mailboxes.

diffstat:

 src/doveadm/doveadm-mail-iter.c |  29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diffs (61 lines):

diff -r 7808096bb674 -r 63555663efbc src/doveadm/doveadm-mail-iter.c
--- a/src/doveadm/doveadm-mail-iter.c	Mon May 06 17:27:36 2013 +0300
+++ b/src/doveadm/doveadm-mail-iter.c	Mon May 06 17:30:07 2013 +0300
@@ -25,6 +25,8 @@
 {
 	struct doveadm_mail_iter *iter;
 	struct mailbox_header_lookup_ctx *headers_ctx;
+	const char *errstr;
+	enum mail_error error;
 
 	iter = i_new(struct doveadm_mail_iter, 1);
 	iter->ctx = ctx;
@@ -33,8 +35,13 @@
 	iter->search_args = search_args;
 
 	if (mailbox_sync(iter->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
-		i_error("Syncing mailbox %s failed: %s", info->vname,
-			mailbox_get_last_error(iter->box, NULL));
+		errstr = mailbox_get_last_error(iter->box, &error);
+		if (error == MAIL_ERROR_NOTFOUND) {
+			/* just ignore this mailbox */
+			*iter_r = iter;
+			return 0;
+		}
+		i_error("Syncing mailbox %s failed: %s", info->vname, errstr);
 		doveadm_mail_failed_mailbox(ctx, iter->box);
 		mailbox_free(&iter->box);
 		i_free(iter);
@@ -58,13 +65,17 @@
 {
 	int ret = 0;
 
-	if (mailbox_search_deinit(&iter->search_ctx) < 0) {
-		i_error("Searching mailbox %s failed: %s",
-			mailbox_get_vname(iter->box),
-			mailbox_get_last_error(iter->box, NULL));
-		ret = -1;
+	if (iter->search_ctx != NULL) {
+		if (mailbox_search_deinit(&iter->search_ctx) < 0) {
+			i_error("Searching mailbox %s failed: %s",
+				mailbox_get_vname(iter->box),
+				mailbox_get_last_error(iter->box, NULL));
+			ret = -1;
+		}
 	}
-	if (commit) {
+	if (iter->t == NULL)
+		;
+	else if (commit) {
 		if (mailbox_transaction_commit(&iter->t) < 0) {
 			i_error("Committing mailbox %s failed: %s",
 				mailbox_get_vname(iter->box),
@@ -123,6 +134,8 @@
 bool doveadm_mail_iter_next(struct doveadm_mail_iter *iter,
 			    struct mail **mail_r)
 {
+	if (iter->search_ctx == NULL)
+		return FALSE;
 	return mailbox_search_next(iter->search_ctx, mail_r);
 }
 


More information about the dovecot-cvs mailing list