]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm dump log: Use shared lib-index code for updating modseq
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 27 Mar 2017 13:33:30 +0000 (16:33 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Mar 2017 17:56:12 +0000 (20:56 +0300)
When MAIL_TRANSACTION_MODSEQ_UPDATE records were seen, the printed modseqs
afterwards weren't correct.

Now that mail_transaction_update_modseq() is used, we don't need to keep
this code synchronized with it.

src/doveadm/doveadm-dump-log.c

index eb823a2a89c26297255d10da180a5bf395eece87..e762225373a39267d8f64956b807aff1b187fab6 100644 (file)
@@ -4,7 +4,7 @@
 #include "istream.h"
 #include "hex-binary.h"
 #include "mail-index-private.h"
-#include "mail-transaction-log.h"
+#include "mail-transaction-log-private.h"
 #include "doveadm-dump.h"
 
 #include <stdio.h>
@@ -44,27 +44,6 @@ static void dump_hdr(struct istream *input, uint64_t *modseq_r)
        *modseq_r = hdr.initial_modseq;
 }
 
-static bool
-mail_transaction_header_has_modseq(const struct mail_transaction_header *hdr)
-{
-       switch (hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
-       case MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT:
-       case MAIL_TRANSACTION_EXPUNGE_GUID | MAIL_TRANSACTION_EXPUNGE_PROT:
-               if ((hdr->type & MAIL_TRANSACTION_EXTERNAL) == 0) {
-                       /* ignore expunge requests */
-                       break;
-               }
-       case MAIL_TRANSACTION_APPEND:
-       case MAIL_TRANSACTION_FLAG_UPDATE:
-       case MAIL_TRANSACTION_KEYWORD_UPDATE:
-       case MAIL_TRANSACTION_KEYWORD_RESET:
-       case MAIL_TRANSACTION_ATTRIBUTE_UPDATE:
-               /* these changes increase modseq */
-               return TRUE;
-       }
-       return FALSE;
-}
-
 static const char *log_record_type(unsigned int type)
 {
        const char *name;
@@ -514,11 +493,6 @@ static int dump_record(struct istream *input, uint64_t *modseq)
 
        printf("record: offset=%"PRIuUOFF_T", type=%s, size=%u",
               input->v_offset, log_record_type(hdr.type), hdr_size);
-       if (*modseq > 0 && mail_transaction_header_has_modseq(&hdr)) {
-               *modseq += 1;
-               printf(", modseq=%llu", (unsigned long long)*modseq);
-       }
-       printf("\n");
 
        i_stream_skip(input, sizeof(hdr));
        size_t data_size = hdr_size - sizeof(hdr);
@@ -529,6 +503,13 @@ static int dump_record(struct istream *input, uint64_t *modseq)
                i_fatal("rec data read() %"PRIuSIZE_T" != %"PRIuSIZE_T,
                        size, data_size);
        }
+
+       uint64_t prev_modseq = *modseq;
+       mail_transaction_update_modseq(&hdr, data, modseq);
+       if (*modseq > prev_modseq)
+               printf(", modseq=%llu", (unsigned long long)*modseq);
+       printf("\n");
+
        log_record_print(&hdr, data, data_size, modseq);
        i_stream_skip(input, data_size);
        return 1;