Mercurial > dovecot > core-2.2
changeset 19693:dacdabcd8085
pop3-migration: Ignore mails returned as expunged by pop3c.
Whether the -ERR actually meant they were expunged or not is another
issue, but the answer to that belongs to pop3c code. MAIL_ERROR_EXPUNGED
in any case can be safely handled this way here.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 01 Feb 2016 19:08:24 +0200 |
parents | f1265c5c323a |
children | ef4bd9f4954c |
files | src/plugins/pop3-migration/pop3-migration-plugin.c |
diffstat | 1 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/pop3-migration/pop3-migration-plugin.c Mon Feb 01 19:07:59 2016 +0200 +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c Mon Feb 01 19:08:24 2016 +0200 @@ -235,12 +235,15 @@ { struct istream *input; struct message_size hdr_size; + const char *errstr; + enum mail_error error; bool have_eoh; if (mail_get_hdr_stream(mail, &hdr_size, &input) < 0) { + errstr = mailbox_get_last_error(mail->box, &error); i_error("pop3_migration: Failed to get header for msg %u: %s", - mail->seq, mailbox_get_last_error(mail->box, NULL)); - return -1; + mail->seq, errstr); + return error == MAIL_ERROR_EXPUNGED ? 0 : -1; } if (pop3_migration_get_hdr_sha1(mail->seq, input, hdr_size.physical_size, @@ -251,7 +254,7 @@ index_mail_cache_add_idx(imail, get_cache_idx(mail), sha1_r, SHA1_RESULTLEN); - return 0; + return 1; } /* The empty "end of headers" line is missing. Either this means that @@ -274,9 +277,10 @@ (and/or RETR) and we'll parse the header ourself from it. This should work around any similar bugs in all IMAP/POP3 servers. */ if (mail_get_stream(mail, &hdr_size, NULL, &input) < 0) { + errstr = mailbox_get_last_error(mail->box, &error); i_error("pop3_migration: Failed to get body for msg %u: %s", - mail->seq, mailbox_get_last_error(mail->box, NULL)); - return -1; + mail->seq, errstr); + return error == MAIL_ERROR_EXPUNGED ? 0 : -1; } return pop3_migration_get_hdr_sha1(mail->seq, input, hdr_size.physical_size, @@ -457,11 +461,12 @@ while (mailbox_search_next(ctx, &mail)) { map = array_idx_modifiable_i(msg_map, mail->seq-1); - if (get_hdr_sha1(mail, map->hdr_sha1) < 0) { + if ((ret = get_hdr_sha1(mail, map->hdr_sha1)) < 0) { ret = -1; break; } - map->hdr_sha1_set = TRUE; + if (ret > 0) + map->hdr_sha1_set = TRUE; } if (mailbox_search_deinit(&ctx) < 0) { @@ -470,7 +475,7 @@ ret = -1; } (void)mailbox_transaction_commit(&t); - return ret; + return ret < 0 ? -1 : 0; } static int @@ -645,7 +650,11 @@ } missing_uids_count = 0; for (pop3_idx = 0; pop3_idx < pop3_count; pop3_idx++) { - if (pop3_map[pop3_idx].imap_uid == 0) { + if (pop3_map[pop3_idx].imap_uid != 0) { + /* matched */ + } else if (!pop3_map[pop3_idx].common.hdr_sha1_set) { + /* we treated this mail as expunged - ignore */ + } else { if (first_missing_idx == (uint32_t)-1) first_missing_idx = pop3_idx; missing_uids_count++;