{
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,
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
(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,
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) {
ret = -1;
}
(void)mailbox_transaction_commit(&t);
- return ret;
+ return ret < 0 ? -1 : 0;
}
static int
}
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++;