changeset 22300:2c78da6b9590

lib-index, lib-storage: Add mail_index_header.last_temp_file_scan 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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 28 Jun 2017 19:41:21 +0300
parents d8bb722cde68
children d86a691543b4
files 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
diffstat 4 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-map-hdr.c	Mon Jun 26 18:59:17 2017 +0300
+++ b/src/lib-index/mail-index-map-hdr.c	Wed Jun 28 19:41:21 2017 +0300
@@ -293,7 +293,7 @@
 		/* 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";
--- a/src/lib-index/mail-index.h	Mon Jun 26 18:59:17 2017 +0300
+++ b/src/lib-index/mail-index.h	Wed Jun 28 19:41:21 2017 +0300
@@ -106,7 +106,7 @@
 	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;
--- a/src/lib-storage/index/index-storage.c	Mon Jun 26 18:59:17 2017 +0300
+++ b/src/lib-storage/index/index-storage.c	Wed Jun 28 19:41:21 2017 +0300
@@ -852,6 +852,22 @@
 	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;
--- a/src/lib-storage/index/index-storage.h	Mon Jun 26 18:59:17 2017 +0300
+++ b/src/lib-storage/index/index-storage.h	Wed Jun 28 19:41:21 2017 +0300
@@ -81,6 +81,8 @@
 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);