]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3-migration: "first POP3 msg" warning didn't actually show the first one.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Sep 2016 10:47:42 +0000 (13:47 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Sep 2016 11:44:51 +0000 (14:44 +0300)
It was showing the first index in an array, which had nothing to do with
being the first POP3 message number.

src/plugins/pop3-migration/pop3-migration-plugin.c

index 943a5b9d3cadf3445ca02d41ccc9d78cd085becf..05138bf318703adc0b74c9a358d2490beb440c94 100644 (file)
@@ -608,7 +608,7 @@ pop3_uidl_assign_by_hdr_hash(struct mailbox *box, struct mailbox *pop3_box)
        struct imap_msg_map *imap_map;
        unsigned int pop3_idx, imap_idx, pop3_count, imap_count;
        unsigned int first_seq, missing_uids_count;
-       uint32_t first_missing_idx = (uint32_t)-1;
+       uint32_t first_missing_idx = 0, first_missing_seq = (uint32_t)-1;
        int ret;
 
        first_seq = mbox->first_unfound_idx+1;
@@ -656,8 +656,11 @@ pop3_uidl_assign_by_hdr_hash(struct mailbox *box, struct mailbox *pop3_box)
                } 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)
+                       uint32_t seq = pop3_map[pop3_idx].pop3_seq;
+                       if (first_missing_seq > seq) {
+                               first_missing_seq = seq;
                                first_missing_idx = pop3_idx;
+                       }
                        missing_uids_count++;
                }
        }
@@ -666,8 +669,7 @@ pop3_uidl_assign_by_hdr_hash(struct mailbox *box, struct mailbox *pop3_box)
 
                str_printfa(str, "pop3_migration: %u POP3 messages have no "
                            "matching IMAP messages (first POP3 msg %u UIDL %s)",
-                           missing_uids_count,
-                           pop3_map[first_missing_idx].pop3_seq,
+                           missing_uids_count, first_missing_seq,
                            pop3_map[first_missing_idx].pop3_uidl);
                if (imap_count + missing_uids_count == pop3_count) {
                        str_append(str, " - all IMAP messages were found "