[dovecot-cvs] dovecot/src/lib-index/mbox mbox-index.c,1.75,1.76 mbox-sync-full.c,1.12,1.13

cras at procontrol.fi cras at procontrol.fi
Mon Jul 21 18:35:41 EEST 2003


Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv23230/lib-index/mbox

Modified Files:
	mbox-index.c mbox-sync-full.c 
Log Message:
Removed .imap.index.tree file. For now we'll just rewrite .imap.index file
whenever there's expunges. "Expunge binary tree" might be added later, but
it's not really useful until you have thousands of messages in mailbox and
you're deleting old messages from it.



Index: mbox-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-index.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- mbox-index.c	19 May 2003 06:56:46 -0000	1.75
+++ mbox-index.c	21 Jul 2003 14:35:39 -0000	1.76
@@ -793,13 +793,16 @@
 }
 
 static int mbox_index_expunge(struct mail_index *index,
-			      struct mail_index_record *rec,
-			      unsigned int seq, int external_change)
+			      struct mail_index_record *first_rec,
+			      struct mail_index_record *last_rec,
+			      unsigned int first_seq, unsigned int last_seq,
+			      int external_change)
 {
-	if (!mail_index_expunge(index, rec, seq, external_change))
+	if (!mail_index_expunge(index, first_rec, last_rec,
+				first_seq, last_seq, external_change))
 		return FALSE;
 
-	if (seq == 1) {
+	if (first_seq == 1) {
 		/* Our message containing X-IMAPbase was deleted.
 		   Get it back there. */
 		index->header->flags |= MAIL_INDEX_FLAG_DIRTY_MESSAGES |

Index: mbox-sync-full.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-sync-full.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mbox-sync-full.c	6 Mar 2003 19:23:45 -0000	1.12
+++ mbox-sync-full.c	21 Jul 2003 14:35:39 -0000	1.13
@@ -127,9 +127,11 @@
         struct mail_index_update *update;
 	struct message_size hdr_parsed_size;
 	struct mbox_header_context ctx;
+	struct mail_index_record *first_rec, *last_rec;
 	uoff_t header_offset, body_offset, offset;
 	uoff_t hdr_size, body_size;
 	unsigned char current_digest[16];
+	unsigned int first_seq, last_seq;
 	int hdr_size_fixed;
 
 	*next_rec = NULL;
@@ -138,6 +140,8 @@
 	skip_line(input);
 	header_offset = input->v_offset;
 
+	first_rec = last_rec = NULL;
+	first_seq = last_seq = 0;
 	hdr_size = 0; body_offset = 0; hdr_size_fixed = FALSE;
 	do {
 		if (!mbox_mail_get_location(index, rec, NULL, NULL, &body_size))
@@ -221,16 +225,30 @@
 
 			if (!index->update_end(update))
 				return FALSE;
-
-			*next_rec = rec;
 			break;
 		}
 
 		/* try next message */
-		(void)index->expunge(index, rec, seq, TRUE);
-		rec = index->next(index, rec);
+		if (first_rec == NULL) {
+			first_rec = rec;
+			first_seq = seq;
+		}
+		last_rec = rec;
+		last_seq = seq;
+
+		rec = index->next(index, rec); seq++;
 	} while (rec != NULL);
 
+	if (first_rec == NULL)
+		*next_rec = rec == NULL ? NULL : index->next(index, rec);
+	else {
+		if (!index->expunge(index, first_rec, last_rec,
+				    first_seq, last_seq, TRUE))
+			return FALSE;
+
+		*next_rec = index->lookup(index, first_seq);
+	}
+
 	return TRUE;
 }
 
@@ -296,14 +314,13 @@
 		}
 
 		seq++;
-		rec = index->next(index, rec);
 	}
 
 	/* delete the rest of the records */
-	while (rec != NULL) {
-		(void)index->expunge(index, rec, seq, TRUE);
-
-		rec = index->next(index, rec);
+	if (rec != NULL) {
+		if (!index->expunge(index, rec, INDEX_END_RECORD(index)-1,
+				    seq, index->header->messages_count, TRUE))
+			return FALSE;
 	}
 
 	if (!dirty && (index->header->flags & MAIL_INDEX_FLAG_DIRTY_MESSAGES)) {



More information about the dovecot-cvs mailing list