From: Aki Tuomi Date: Wed, 5 Sep 2018 16:34:20 +0000 (+0300) Subject: pop3: Do not expunge \Deleted mails without QUIT X-Git-Tag: 2.2.36.1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b068160536f4147a93df8a4964f0751139726196;p=thirdparty%2Fdovecot%2Fcore.git pop3: Do not expunge \Deleted mails without QUIT Prevents loss of email if connection is unexpectedly terminated. --- diff --git a/src/pop3/pop3-client.h b/src/pop3/pop3-client.h index d2c6c0eda8..d1116cfa79 100644 --- a/src/pop3/pop3-client.h +++ b/src/pop3/pop3-client.h @@ -103,6 +103,7 @@ struct client { unsigned int anvil_sent:1; unsigned int message_uidls_save:1; unsigned int delete_success:1; + unsigned int quit_seen:1; }; struct pop3_module_register { diff --git a/src/pop3/pop3-commands.c b/src/pop3/pop3-commands.c index f4375d512b..c09a85e414 100644 --- a/src/pop3/pop3-commands.c +++ b/src/pop3/pop3-commands.c @@ -268,7 +268,7 @@ bool client_update_mails(struct client *client) mail_search_args_unref(&search_args); while (mailbox_search_next(ctx, &mail)) { - if (seq_range_exists(&deleted_msgs, mail->seq)) + if (client->quit_seen && seq_range_exists(&deleted_msgs, mail->seq)) client_expunge(client, mail); else if (seq_range_exists(&seen_msgs, mail->seq)) mail_update_flags(mail, MODIFY_ADD, MAIL_SEEN); @@ -282,6 +282,7 @@ bool client_update_mails(struct client *client) static int cmd_quit(struct client *client, const char *args ATTR_UNUSED) { + client->quit_seen = TRUE; if (client->deleted || client->seen_bitmask != NULL) { if (!client_update_mails(client)) { client_send_storage_error(client);