]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index, lib-storage: Add mail_index_header.last_temp_file_scan
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 28 Jun 2017 16:41:21 +0000 (19:41 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 3 Jul 2017 12:25:27 +0000 (15:25 +0300)
Also add index_mailbox_update_last_temp_file_scan() for easily updating it.

This is reusing an old "sync timestamp" field. Because it was a timestamp,
it doesn't matter if the old data still exists in it. This field could have
been added as an extension, but that's more work and this feature is generic
enough that it should be useful for many of the mail storage backends.

src/lib-index/mail-index-map-hdr.c
src/lib-index/mail-index.h
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h

index 59b0c7f93d62d70044da3f7791894f7f995d44ba..1caa3f1a2ef076e3fa1ce328bda30f9fc20b5fe3 100644 (file)
@@ -293,7 +293,7 @@ int mail_index_map_check_header(struct mail_index_map *map,
                /* pre-v2.2 (although should have been done in v2.1 already):
                   make sure the old unused fields are cleared */
                map->hdr.unused_old_sync_size = 0;
-               map->hdr.unused_old_sync_stamp = 0;
+               map->hdr.last_temp_file_scan = 0;
        }
        if (hdr->first_recent_uid == 0) {
                *error_r = "first_recent_uid=0";
index fb6b19275cdb44108a0e9671231c59fd1b5e25fc..1e1a289d7d9460538d69b5a1ceb7e3c7e02803cf 100644 (file)
@@ -106,7 +106,7 @@ struct mail_index_header {
        uint32_t log_file_head_offset;
 
        uint64_t unused_old_sync_size;
-       uint32_t unused_old_sync_stamp;
+       uint32_t last_temp_file_scan;
 
        /* daily first UIDs that have been added to index. */
        uint32_t day_stamp;
index f3fc07f7295d6c6056a6f46837e3cb9c6e1e3293..7735516c40c28469402ce42580a24808e6b5b87b 100644 (file)
@@ -852,6 +852,22 @@ int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest)
        return 0;
 }
 
+int index_mailbox_update_last_temp_file_scan(struct mailbox *box)
+{
+       uint32_t last_temp_file_scan = ioloop_time;
+       struct mail_index_transaction *trans =
+               mail_index_transaction_begin(box->view,
+                       MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
+       mail_index_update_header(trans,
+               offsetof(struct mail_index_header, last_temp_file_scan),
+               &last_temp_file_scan, sizeof(last_temp_file_scan), TRUE);
+       if (mail_index_transaction_commit(&trans) < 0) {
+               mailbox_set_index_error(box);
+               return -1;
+       }
+       return 0;
+}
+
 bool index_storage_is_readonly(struct mailbox *box)
 {
        return (box->flags & MAILBOX_FLAG_READONLY) != 0;
index 28dc66d649a8f16f03d481aca76a94bf6abf8e25..f3d86fa5f18323316c71788a261e989718ff90c4 100644 (file)
@@ -81,6 +81,8 @@ int index_storage_mailbox_delete(struct mailbox *box);
 int index_storage_mailbox_delete_dir(struct mailbox *box, bool mailbox_deleted);
 int index_storage_mailbox_rename(struct mailbox *src, struct mailbox *dest);
 
+int index_mailbox_update_last_temp_file_scan(struct mailbox *box);
+
 bool index_storage_is_readonly(struct mailbox *box);
 bool index_storage_is_inconsistent(struct mailbox *box);