From: Alexandre Roux Date: Tue, 17 Jun 2025 06:41:06 +0000 (+0200) Subject: imap: Avoid logging an error if unhibernation fails due to mailbox being deleted X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6105041acee8bfc574bad764022d85fb70263aa1;p=thirdparty%2Fdovecot%2Fcore.git imap: Avoid logging an error if unhibernation fails due to mailbox being deleted --- diff --git a/src/imap/imap-master-client.c b/src/imap/imap-master-client.c index cc5cd60f2a..952c085f92 100644 --- a/src/imap/imap-master-client.c +++ b/src/imap/imap-master-client.c @@ -394,6 +394,10 @@ imap_master_client_input_args(struct connection *conn, const char *const *args, event_unref(&event); client_destroy(imap_client, "Client state initialization failed"); return -1; + case IMAP_STATE_INCONSISTENT: + event_unref(&event); + client_destroy(imap_client, "Client state inconsistent"); + return 0; case IMAP_STATE_OK: break; } diff --git a/src/imap/imap-state.c b/src/imap/imap-state.c index 9790352847..ccbe50ceca 100644 --- a/src/imap/imap-state.c +++ b/src/imap/imap-state.c @@ -574,8 +574,17 @@ import_state_mailbox_open(struct client *client, flags |= MAILBOX_FLAG_DROP_RECENT; box = mailbox_alloc(ns->list, state->vname, flags); if (mailbox_open(box) < 0) { - *error_r = t_strdup_printf("Couldn't open mailbox: %s", - mailbox_get_last_internal_error(box, NULL)); + enum mail_error error; + const char *errstr = mailbox_get_last_internal_error(box, &error); + const char *full_errstr = t_strdup_printf("Couldn't open mailbox: %s", errstr); + if (error == MAIL_ERROR_NOTFOUND) { + e_debug(box->event, "Unhibernation failed to open mailbox: %s", errstr); + client_disconnect_with_error(client, + "IMAP session state is inconsistent, please relogin."); + mailbox_free(&box); + return IMAP_STATE_INCONSISTENT; + } + *error_r = full_errstr; mailbox_free(&box); return IMAP_STATE_ERROR; } diff --git a/src/imap/imap-state.h b/src/imap/imap-state.h index 0c5a1cc125..ed690b7959 100644 --- a/src/imap/imap-state.h +++ b/src/imap/imap-state.h @@ -6,6 +6,7 @@ enum imap_state_result { IMAP_STATE_OK, /* Success */ IMAP_STATE_CORRUPTED, /* Data corruption or invalid state */ IMAP_STATE_ERROR, /* General error (e.g., permission, resource issues) */ + IMAP_STATE_INCONSISTENT /* State inconsistency (e.g., mailbox not found) */ }; /* Export the IMAP client state to the given buffer. Returns 1 if ok,