From 16f8ce952591d3b172d8e563a62351880d8f9762 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Wed, 5 Sep 2018 19:34:20 +0300 Subject: [PATCH] pop3: Do not expunge \Deleted mails without QUIT Prevents loss of email if connection is unexpectedly terminated. --- src/pop3/pop3-client.h | 1 + src/pop3/pop3-commands.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pop3/pop3-client.h b/src/pop3/pop3-client.h index a785ef4638..51af0793ce 100644 --- a/src/pop3/pop3-client.h +++ b/src/pop3/pop3-client.h @@ -103,6 +103,7 @@ struct client { bool anvil_sent:1; bool message_uidls_save:1; bool delete_success:1; + bool quit_seen:1; }; struct pop3_module_register { diff --git a/src/pop3/pop3-commands.c b/src/pop3/pop3-commands.c index 2dbdec5521..dcbced3589 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); -- 2.47.3