Skip to content

Commit

Permalink
lib-storage: Add explicit MAIL_ERROR_LOOKUP_ABORT error
Browse files Browse the repository at this point in the history
The MAIL_ERROR_NOTPOSSIBLE was a bit too generic to assume to mean the same
thing. It doesn't look like there are any external plugins that break
because of this change.
  • Loading branch information
sirainen committed Feb 19, 2017
1 parent da29d3a commit 37038df
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/doveadm/doveadm-mail.c
Expand Up @@ -84,6 +84,8 @@ void doveadm_mail_failed_error(struct doveadm_mail_cmd_context *ctx,
case MAIL_ERROR_LIMIT:
exit_code = DOVEADM_EX_NOTPOSSIBLE;
break;
case MAIL_ERROR_LOOKUP_ABORTED:
break;
}
/* tempfail overrides all other exit codes, otherwise use whatever
error happened first */
Expand Down
1 change: 1 addition & 0 deletions src/imap/imap-commands-util.c
Expand Up @@ -141,6 +141,7 @@ imap_get_error_string(struct client_command_context *cmd,
case MAIL_ERROR_NONE:
break;
case MAIL_ERROR_TEMP:
case MAIL_ERROR_LOOKUP_ABORTED: /* BUG: shouldn't be visible here */
resp_code = IMAP_RESP_CODE_SERVERBUG;
break;
case MAIL_ERROR_NOTPOSSIBLE:
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/index-mailbox-size.c
Expand Up @@ -331,7 +331,7 @@ index_mailbox_vsize_hdr_add_missing(struct mailbox_vsize_update *update,
}
ret = mail_get_virtual_size(mail, &vsize);
if (ret < 0 &&
mailbox_get_last_mail_error(update->box) == MAIL_ERROR_NOTPOSSIBLE) {
mailbox_get_last_mail_error(update->box) == MAIL_ERROR_LOOKUP_ABORTED) {
/* abort and finish on background */
i_assert(mails_left == 0);

Expand Down
4 changes: 2 additions & 2 deletions src/lib-storage/index/index-search.c
Expand Up @@ -82,8 +82,8 @@ static void search_cur_mail_failed(struct index_search_context *ctx)
case MAIL_ERROR_EXPUNGED:
ctx->mail_ctx.seen_lost_data = TRUE;
break;
case MAIL_ERROR_NOTPOSSIBLE:
/* lookup_abort hit */
case MAIL_ERROR_LOOKUP_ABORTED:
/* expected failure */
break;
default:
search_set_failed(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/index-sort.c
Expand Up @@ -43,7 +43,7 @@ index_sort_program_set_mail_failed(struct mail_search_sort_program *program,
switch (mailbox_get_last_mail_error(mail->box)) {
case MAIL_ERROR_EXPUNGED:
break;
case MAIL_ERROR_NOTPOSSIBLE:
case MAIL_ERROR_LOOKUP_ABORTED:
/* just change the error message */
mail_storage_set_error(program->t->box->storage, MAIL_ERROR_LIMIT,
"Requested sort would have taken too long.");
Expand Down
3 changes: 3 additions & 0 deletions src/lib-storage/mail-error.h
Expand Up @@ -51,6 +51,9 @@ enum mail_error {
MAIL_ERROR_INVALIDDATA,
/* Operation ran against some kind of a limit. */
MAIL_ERROR_LIMIT,
/* Operation couldn't be finished as efficiently as required by
mail.lookup_abort. */
MAIL_ERROR_LOOKUP_ABORTED,

/* FIXME: Obsolete - remove in v2.3 */
MAIL_ERROR_NOSPACE = MAIL_ERROR_NOQUOTA
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/mail.c
Expand Up @@ -247,7 +247,7 @@ int mail_get_header_stream(struct mail *mail,

void mail_set_aborted(struct mail *mail)
{
mail_storage_set_error(mail->box->storage, MAIL_ERROR_NOTPOSSIBLE,
mail_storage_set_error(mail->box->storage, MAIL_ERROR_LOOKUP_ABORTED,
"Mail field not cached");
}

Expand Down
4 changes: 2 additions & 2 deletions src/pop3/pop3-client.c
Expand Up @@ -97,7 +97,7 @@ pop3_mail_get_size(struct client *client, struct mail *mail, uoff_t *size_r)
if (ret == 0)
return 0;

if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_NOTPOSSIBLE)
if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_LOOKUP_ABORTED)
return -1;

/* virtual size not available with a fast lookup.
Expand All @@ -108,7 +108,7 @@ pop3_mail_get_size(struct client *client, struct mail *mail, uoff_t *size_r)
if (ret == 0)
return 0;

if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_NOTPOSSIBLE)
if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_LOOKUP_ABORTED)
return -1;

/* no way to quickly get the size. fallback to doing a slow virtual
Expand Down

0 comments on commit 37038df

Please sign in to comment.