changeset 22990:39eb7899c21d

pop3: Do not expunge \Deleted mails without QUIT Prevents loss of email if connection is unexpectedly terminated.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Wed, 05 Sep 2018 19:34:20 +0300
parents 4e9251b0435d
children d8c1409c1ec1
files src/pop3/pop3-client.h src/pop3/pop3-commands.c
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/pop3/pop3-client.h	Wed Jul 25 13:17:45 2018 +0300
+++ b/src/pop3/pop3-client.h	Wed Sep 05 19:34:20 2018 +0300
@@ -103,6 +103,7 @@
 	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 {
--- a/src/pop3/pop3-commands.c	Wed Jul 25 13:17:45 2018 +0300
+++ b/src/pop3/pop3-commands.c	Wed Sep 05 19:34:20 2018 +0300
@@ -268,7 +268,7 @@
 	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 @@
 
 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);