[dovecot-cvs] dovecot/src/lib-index mail-index-transaction.c, 1.10, 1.11 mail-index.h, 1.115, 1.116

cras at procontrol.fi cras at procontrol.fi
Sun Jun 20 06:25:35 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv336/src/lib-index

Modified Files:
	mail-index-transaction.c mail-index.h 
Log Message:
mailbox_save() and mailbox_copy() functions can now return the saved mail so
it can be immediately queried. Implemented UIDPLUS extension using it.
Maildir implementation missing, so it crashes with it for now.. APPEND with
mbox now doesn't require resyncing the mailbox since it updates indexes
directly.



Index: mail-index-transaction.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mail-index-transaction.c	14 Jun 2004 04:27:44 -0000	1.10
+++ mail-index-transaction.c	20 Jun 2004 03:25:33 -0000	1.11
@@ -161,6 +161,18 @@
 	rec->uid = uid;
 }
 
+static struct mail_index_record *
+mail_index_lookup_append_rec(struct mail_index_transaction *t, uint32_t seq)
+{
+	size_t pos;
+
+	i_assert(seq >= t->first_new_seq && seq <= t->last_new_seq);
+
+	pos = (seq - t->first_new_seq) * t->view->index->record_size;
+	return buffer_get_space_unsafe(t->appends, pos,
+				       t->view->index->record_size);
+}
+
 void mail_index_expunge(struct mail_index_transaction *t, uint32_t seq)
 {
         struct mail_transaction_expunge exp, *data;
@@ -288,15 +300,10 @@
 			     enum mail_flags flags, keywords_mask_t keywords)
 {
 	struct mail_index_record *rec;
-	size_t pos;
 
 	if (t->first_new_seq != 0 && seq >= t->first_new_seq) {
 		/* just appended message, modify it directly */
-		i_assert(seq > 0 && seq <= t->last_new_seq);
-
-		pos = (seq - t->first_new_seq) * t->view->index->record_size;
-		rec = buffer_get_space_unsafe(t->appends, pos,
-					      t->view->index->record_size);
+                rec = mail_index_lookup_append_rec(t, seq);
 		mail_index_record_modify_flags(rec, modify_type,
 					       flags, keywords);
 		return;
@@ -467,33 +474,15 @@
 	memcpy(seq_p+1, record, record_size);
 }
 
-static void mail_index_update_record(struct mail_index_transaction *t,
-				     uint32_t seq, size_t offset,
-				     const void *record, size_t record_size)
-{
-	struct mail_index *index = t->view->index;
-	struct mail_index_record *rec;
-	size_t pos;
-
-	i_assert(seq > 0 && seq <= t->last_new_seq);
-
-	pos = (seq - t->first_new_seq) * index->record_size;
-	rec = buffer_get_space_unsafe(t->appends, pos,
-				      index->record_size);
-
-	memcpy(PTR_OFFSET(rec, offset), record, record_size);
-}
-
 void mail_index_update_cache(struct mail_index_transaction *t,
 			     uint32_t seq, uint32_t offset)
 {
+	struct mail_index_record *rec;
+
 	if (t->first_new_seq != 0 && seq >= t->first_new_seq) {
 		/* just appended message, modify it directly */
-		size_t rec_offset;
-
-		rec_offset = offsetof(struct mail_index_record, cache_offset);
-		mail_index_update_record(t, seq, rec_offset,
-					 &offset, sizeof(offset));
+		rec = mail_index_lookup_append_rec(t, seq);
+		rec->cache_offset = offset;
 	} else {
 		mail_index_update_seq_buffer(&t->cache_updates, seq,
 					     &offset, sizeof(offset));
@@ -505,15 +494,16 @@
 				 const void *data)
 {
 	struct mail_index *index = t->view->index;
+	struct mail_index_record *rec;
 
 	i_assert(data_id < index->extra_records_count);
 
 	if (t->first_new_seq != 0 && seq >= t->first_new_seq) {
 		/* just appended message, modify it directly */
 		/* FIXME: do data_id mapping conversion */
-		mail_index_update_record(t, seq,
-			index->extra_records[data_id].offset, data,
-			index->extra_records[data_id].size);
+		rec = mail_index_lookup_append_rec(t, seq);
+		memcpy(PTR_OFFSET(rec, index->extra_records[data_id].offset),
+		       data, index->extra_records[data_id].size);
 	} else {
 		mail_index_update_seq_buffer(&t->extra_rec_updates[data_id],
 			seq, data, index->extra_records[data_id].size);
@@ -532,3 +522,9 @@
 	for (; size > 0; size--)
 		t->hdr_mask[offset++] = 1;
 }
+
+const struct mail_index_record *
+mail_index_lookup_append(struct mail_index_transaction *t, uint32_t seq)
+{
+	return mail_index_lookup_append_rec(t, seq);
+}

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- mail-index.h	14 Jun 2004 04:27:44 -0000	1.115
+++ mail-index.h	20 Jun 2004 03:25:33 -0000	1.116
@@ -277,6 +277,10 @@
 void mail_index_update_extra_rec(struct mail_index_transaction *t,
 				 uint32_t seq, uint32_t data_id,
 				 const void *data);
+/* Returns given appended message, with all updates that have been done
+   to it since the append. */
+const struct mail_index_record *
+mail_index_lookup_append(struct mail_index_transaction *t, uint32_t seq);
 
 /* Returns the last error code. */
 enum mail_index_error mail_index_get_last_error(struct mail_index *index);



More information about the dovecot-cvs mailing list