dovecot-2.0: Removed mail_update_uid() / mail_index_update_uid().

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 30 23:21:23 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/b265dee142a6
changeset: 11665:b265dee142a6
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 30 21:21:19 2010 +0100
description:
Removed mail_update_uid() / mail_index_update_uid().
It was working properly only with mdbox and there wasn't really a need for it.

diffstat:

 src/doveadm/doveadm-dump-log.c                     |  14 ----
 src/lib-index/mail-index-sync-update.c             |  43 --------------
 src/lib-index/mail-index-transaction-export.c      |  60 +------------------
 src/lib-index/mail-index-transaction-finish.c      |   1 -
 src/lib-index/mail-index-transaction-private.h     |   1 -
 src/lib-index/mail-index-transaction-update.c      |  18 ------
 src/lib-index/mail-index.h                         |   7 --
 src/lib-index/mail-transaction-log-file.c          |   1 -
 src/lib-index/mail-transaction-log.h               |   5 -
 src/lib-index/test-mail-index-transaction-finish.c |  33 -----------
 src/lib-index/test-mail-index-transaction-update.c |  26 --------
 src/lib-storage/index/cydir/cydir-mail.c           |   1 -
 src/lib-storage/index/dbox-multi/mdbox-mail.c      |   1 -
 src/lib-storage/index/dbox-multi/mdbox-save.c      |  12 ++++
 src/lib-storage/index/dbox-single/sdbox-mail.c     |   1 -
 src/lib-storage/index/index-mail.c                 |   5 -
 src/lib-storage/index/index-mail.h                 |   1 -
 src/lib-storage/index/index-transaction.c          |   1 -
 src/lib-storage/index/maildir/maildir-mail.c       |   7 --
 src/lib-storage/index/maildir/maildir-save.c       |  62 +--------------------
 src/lib-storage/index/maildir/maildir-storage.h    |   3 -
 src/lib-storage/index/mbox/mbox-mail.c             |   1 -
 src/lib-storage/index/raw/raw-mail.c               |   1 -
 src/lib-storage/mail-storage-private.h             |   1 -
 src/lib-storage/mail-storage.h                     |   6 +-
 src/lib-storage/mail.c                             |   7 --
 src/lib-storage/test-mail.c                        |   6 --
 src/plugins/virtual/virtual-mail.c                 |   1 -
 28 files changed, 18 insertions(+), 308 deletions(-)

diffs (truncated from 749 to 300 lines):

diff -r 372af44dca85 -r b265dee142a6 src/doveadm/doveadm-dump-log.c
--- a/src/doveadm/doveadm-dump-log.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/doveadm/doveadm-dump-log.c	Wed Jun 30 21:21:19 2010 +0100
@@ -52,7 +52,6 @@
 	case MAIL_TRANSACTION_FLAG_UPDATE:
 	case MAIL_TRANSACTION_KEYWORD_UPDATE:
 	case MAIL_TRANSACTION_KEYWORD_RESET:
-	case MAIL_TRANSACTION_UID_UPDATE:
 		/* these changes increase modseq */
 		return TRUE;
 	}
@@ -103,9 +102,6 @@
 	case MAIL_TRANSACTION_EXT_ATOMIC_INC:
 		name = "ext-atomic-inc";
 		break;
-	case MAIL_TRANSACTION_UID_UPDATE:
-		name = "uid-update";
-		break;
 	case MAIL_TRANSACTION_MODSEQ_UPDATE:
 		name = "modseq-update";
 		break;
@@ -396,16 +392,6 @@
 		printf("\n");
 		break;
 	}
-	case MAIL_TRANSACTION_UID_UPDATE: {
-		const struct mail_transaction_uid_update *rec, *end;
-
-		end = CONST_PTR_OFFSET(data, size);
-		for (rec = data; rec < end; rec++) {
-			printf(" - old uid=%u new uid=%u\n",
-			       rec->old_uid, rec->new_uid);
-		}
-		break;
-	}
 	case MAIL_TRANSACTION_MODSEQ_UPDATE: {
 		const struct mail_transaction_modseq_update *rec, *end;
 
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index-sync-update.c	Wed Jun 30 21:21:19 2010 +0100
@@ -301,41 +301,6 @@
 	return TRUE;
 }
 
-static void sync_uid_update(struct mail_index_sync_map_ctx *ctx,
-			    uint32_t old_uid, uint32_t new_uid)
-{
-	struct mail_index_view *view = ctx->view;
-	struct mail_index_map *map;
-	struct mail_index_record *rec;
-	uint32_t old_seq;
-	void *dest;
-
-	if (new_uid < ctx->view->map->hdr.next_uid) {
-		/* uid update is no longer possible */
-		if (sync_update_ignored_change(ctx))
-			view->index->sync_commit_result->ignored_uid_changes++;
-		return;
-	}
-
-	if (!mail_index_lookup_seq(view, old_uid, &old_seq))
-		return;
-
-	map = mail_index_sync_get_atomic_map(ctx);
-	map->hdr.next_uid = new_uid+1;
-	map->rec_map->last_appended_uid = new_uid;
-
-	/* add the new record */
-	dest = sync_append_record(map);
-	rec = MAIL_INDEX_MAP_IDX(map, old_seq-1);
-	rec->uid = new_uid;
-	memcpy(dest, rec, map->hdr.record_size);
-
-	/* @UNSAFE: remove the old record */
-	memmove(rec, PTR_OFFSET(rec, map->hdr.record_size),
-		(map->rec_map->records_count + 1 - old_seq) *
-		map->hdr.record_size);
-}
-
 static int
 sync_modseq_update(struct mail_index_sync_map_ctx *ctx,
 		   const struct mail_transaction_modseq_update *u,
@@ -799,14 +764,6 @@
 		ret = mail_index_sync_keywords_reset(ctx, hdr, rec);
 		break;
 	}
-	case MAIL_TRANSACTION_UID_UPDATE: {
-		const struct mail_transaction_uid_update *rec, *end;
-
-		end = CONST_PTR_OFFSET(data, hdr->size);
-		for (rec = data; rec < end; rec++)
-			sync_uid_update(ctx, rec->old_uid, rec->new_uid);
-		break;
-	}
 	case MAIL_TRANSACTION_MODSEQ_UPDATE: {
 		const struct mail_transaction_modseq_update *rec = data;
 
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index-transaction-export.c
--- a/src/lib-index/mail-index-transaction-export.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index-transaction-export.c	Wed Jun 30 21:21:19 2010 +0100
@@ -336,61 +336,6 @@
 	return change_mask;
 }
 
-static bool
-mail_index_transaction_export_new_uids(struct mail_index_export_context *ctx,
-				       struct mail_index_transaction *t)
-{
-	const struct mail_index_record *appends;
-	const struct mail_transaction_uid_update *updates;
-	unsigned int a, u, append_count, update_count;
-
-	if (!array_is_created(&t->uid_updates)) {
-		/* fast path */
-		if (!array_is_created(&t->appends))
-			return FALSE;
-
-		log_append_buffer(ctx, t->appends.arr.buffer,
-				  MAIL_TRANSACTION_APPEND);
-		return TRUE;
-	}
-	if (!array_is_created(&t->appends)) {
-		log_append_buffer(ctx, t->uid_updates.arr.buffer,
-				  MAIL_TRANSACTION_UID_UPDATE);
-		return TRUE;
-	}
-
-	/* we'll need to merge so that UIDs are only being appended.
-	   appends quite a lot of separate records unnecessarily,
-	   but UID updates are rare.. */
-	appends = array_get(&t->appends, &append_count);
-	updates = array_get(&t->uid_updates, &update_count);
-
-	for (a = u = 0; a < append_count && u < update_count; ) {
-		if (appends[a].uid < updates[u].new_uid) {
-			mail_transaction_log_append_add(ctx->append_ctx,
-					MAIL_TRANSACTION_APPEND,
-					&appends[a], sizeof(appends[a]));
-			a++;
-		} else {
-			mail_transaction_log_append_add(ctx->append_ctx,
-					MAIL_TRANSACTION_UID_UPDATE,
-					&updates[u], sizeof(updates[u]));
-			u++;
-		}
-	}
-	if (a < append_count) {
-		mail_transaction_log_append_add(ctx->append_ctx,
-				MAIL_TRANSACTION_APPEND, &appends[a],
-				(append_count - a) * sizeof(appends[a]));
-	}
-	if (u < update_count) {
-		mail_transaction_log_append_add(ctx->append_ctx,
-				MAIL_TRANSACTION_UID_UPDATE, &updates[u],
-				(update_count - u) * sizeof(updates[u]));
-	}
-	return TRUE;
-}
-
 void mail_index_transaction_export(struct mail_index_transaction *t,
 				   struct mail_transaction_log_append_ctx *append_ctx)
 {
@@ -416,8 +361,11 @@
 		log_append_buffer(&ctx, log_get_hdr_update_buffer(t, TRUE),
 				  MAIL_TRANSACTION_HEADER_UPDATE);
 	}
-	if (mail_index_transaction_export_new_uids(&ctx, t))
+	if (array_is_created(&t->appends)) {
 		change_mask |= MAIL_INDEX_SYNC_TYPE_APPEND;
+		log_append_buffer(&ctx, t->appends.arr.buffer,
+				  MAIL_TRANSACTION_APPEND);
+	}
 
 	if (array_is_created(&t->updates)) {
 		change_mask |= MAIL_INDEX_SYNC_TYPE_FLAGS;
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index-transaction-finish.c
--- a/src/lib-index/mail-index-transaction-finish.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index-transaction-finish.c	Wed Jun 30 21:21:19 2010 +0100
@@ -311,7 +311,6 @@
 
         keyword_updates_convert_to_uids(t);
 	expunges_convert_to_uids(t);
-	mail_index_convert_to_uids(t, (void *)&t->uid_updates);
 	mail_index_convert_to_uids(t, (void *)&t->modseq_updates);
 	mail_index_convert_to_uid_ranges(t, (void *)&t->updates);
 	mail_index_convert_to_uid_ranges(t, &t->keyword_resets);
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index-transaction-private.h
--- a/src/lib-index/mail-index-transaction-private.h	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index-transaction-private.h	Wed Jun 30 21:21:19 2010 +0100
@@ -45,7 +45,6 @@
 	uint32_t min_flagupdate_seq, max_flagupdate_seq;
 
 	ARRAY_DEFINE(modseq_updates, struct mail_transaction_modseq_update);
-	ARRAY_DEFINE(uid_updates, struct mail_transaction_uid_update);
 	ARRAY_DEFINE(expunges, struct mail_transaction_expunge_guid);
 	ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
 	size_t last_update_idx;
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index-transaction-update.c
--- a/src/lib-index/mail-index-transaction-update.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index-transaction-update.c	Wed Jun 30 21:21:19 2010 +0100
@@ -64,8 +64,6 @@
 
 	if (array_is_created(&t->appends))
 		array_free(&t->appends);
-	if (array_is_created(&t->uid_updates))
-		array_free(&t->uid_updates);
 	if (array_is_created(&t->modseq_updates))
 		array_free(&t->modseq_updates);
 	if (array_is_created(&t->expunges))
@@ -107,7 +105,6 @@
 {
 	/* flag updates aren't included in log_updates */
 	t->log_updates = array_is_created(&t->appends) ||
-		array_is_created(&t->uid_updates) ||
 		array_is_created(&t->modseq_updates) ||
 		array_is_created(&t->expunges) ||
 		array_is_created(&t->keyword_resets) ||
@@ -240,21 +237,6 @@
 	}
 }
 
-void mail_index_update_uid(struct mail_index_transaction *t, uint32_t seq,
-			   uint32_t new_uid)
-{
-	struct mail_transaction_uid_update *u;
-
-	if (!array_is_created(&t->uid_updates))
-		i_array_init(&t->uid_updates, 32);
-
-	u = array_append_space(&t->uid_updates);
-	u->old_uid = seq;
-	u->new_uid = new_uid;
-
-	t->log_updates = TRUE;
-}
-
 void mail_index_update_modseq(struct mail_index_transaction *t, uint32_t seq,
 			      uint64_t min_modseq)
 {
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-index.h	Wed Jun 30 21:21:19 2010 +0100
@@ -192,7 +192,6 @@
 	   all of it was written to the same file. */
 	uoff_t commit_size;
 
-	unsigned int ignored_uid_changes;
 	unsigned int ignored_modseq_changes;
 };
 
@@ -425,12 +424,6 @@
 void mail_index_append_finish_uids(struct mail_index_transaction *t,
 				   uint32_t first_uid,
 				   ARRAY_TYPE(seq_range) *uids_r);
-/* Update message's UID. The new UID must not be lower than next_uid at the
-   commit time, otherwise the UID update fails and is just ignored.
-   If there are appends in the same transaction, the updated UIDs must be
-   higher than the append UIDs. */
-void mail_index_update_uid(struct mail_index_transaction *t, uint32_t seq,
-			   uint32_t new_uid);
 /* Expunge record from index. Note that this doesn't affect sequence numbers
    until transaction is committed and mailbox is synced. */
 void mail_index_expunge(struct mail_index_transaction *t, uint32_t seq);
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-transaction-log-file.c	Wed Jun 30 21:21:19 2010 +0100
@@ -852,7 +852,6 @@
 	case MAIL_TRANSACTION_FLAG_UPDATE:
 	case MAIL_TRANSACTION_KEYWORD_UPDATE:
 	case MAIL_TRANSACTION_KEYWORD_RESET:
-	case MAIL_TRANSACTION_UID_UPDATE:
 		/* these changes increase modseq */
 		*cur_modseq += 1;
 		break;
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/mail-transaction-log.h
--- a/src/lib-index/mail-transaction-log.h	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/mail-transaction-log.h	Wed Jun 30 21:21:19 2010 +0100
@@ -39,7 +39,6 @@
 	MAIL_TRANSACTION_KEYWORD_RESET		= 0x00000800,
 	MAIL_TRANSACTION_EXT_ATOMIC_INC		= 0x00001000,
 	MAIL_TRANSACTION_EXPUNGE_GUID		= 0x00002000,
-	MAIL_TRANSACTION_UID_UPDATE		= 0x00004000,
 	MAIL_TRANSACTION_MODSEQ_UPDATE		= 0x00008000,
 	MAIL_TRANSACTION_EXT_HDR_UPDATE32	= 0x00010000,
 	MAIL_TRANSACTION_INDEX_DELETED		= 0x00020000,
@@ -67,10 +66,6 @@
 	uint32_t type; /* enum mail_transaction_type */
 };
 
-struct mail_transaction_uid_update {
-	uint32_t old_uid, new_uid;
-};
-
 struct mail_transaction_modseq_update {
 	uint32_t uid;
 	/* don't use uint64_t here. it adds extra 32 bits of paddiong and also
diff -r 372af44dca85 -r b265dee142a6 src/lib-index/test-mail-index-transaction-finish.c
--- a/src/lib-index/test-mail-index-transaction-finish.c	Wed Jun 30 21:19:59 2010 +0100
+++ b/src/lib-index/test-mail-index-transaction-finish.c	Wed Jun 30 21:21:19 2010 +0100


More information about the dovecot-cvs mailing list