[dovecot-cvs] dovecot/src/lib-storage/index index-expunge.c,1.16,1.17 index-storage.h,1.40,1.41

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


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

Modified Files:
	index-expunge.c index-storage.h 
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: index-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-expunge.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- index-expunge.c	15 Jun 2003 03:42:29 -0000	1.16
+++ index-expunge.c	21 Jul 2003 14:35:39 -0000	1.17
@@ -43,20 +43,36 @@
 	return TRUE;
 }
 
-int index_expunge_mail(struct index_mailbox *ibox,
-		       struct mail_index_record *rec,
-		       unsigned int seq, int notify)
+int index_expunge_mails(struct index_mailbox *ibox,
+			struct mail_index_record *first_rec,
+			struct mail_index_record *last_rec,
+			unsigned int first_seq, unsigned int last_seq,
+			int notify)
 {
-	if (!ibox->index->expunge(ibox->index, rec, seq, FALSE))
+	unsigned int max;
+
+	if (!ibox->index->expunge(ibox->index, first_rec, last_rec,
+				  first_seq, last_seq, FALSE))
 		return FALSE;
 
-	if (seq <= ibox->synced_messages_count) {
-		if (notify) {
-			struct mail_storage *storage = ibox->box.storage;
-			storage->callbacks->expunge(&ibox->box, seq,
-						    storage->callback_context);
+	if (first_seq > ibox->synced_messages_count)
+		return TRUE;
+
+	max = last_seq > ibox->synced_messages_count ?
+		ibox->synced_messages_count : last_seq;
+
+	ibox->synced_messages_count -= max - first_seq + 1;
+	if (notify) {
+		struct mail_storage_callbacks *cb;
+		void *cb_ctx;
+
+		cb = ibox->box.storage->callbacks;
+		cb_ctx = ibox->box.storage->callback_context;
+
+		while (max >= first_seq) {
+			cb->expunge(&ibox->box, first_seq, cb_ctx);
+			max--;
 		}
-		ibox->synced_messages_count--;
 	}
 
 	return TRUE;

Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- index-storage.h	15 Jul 2003 18:26:43 -0000	1.40
+++ index-storage.h	21 Jul 2003 14:35:39 -0000	1.41
@@ -69,9 +69,11 @@
 
 int index_expunge_seek_first(struct index_mailbox *ibox, unsigned int *seq,
 			     struct mail_index_record **rec);
-int index_expunge_mail(struct index_mailbox *ibox,
-		       struct mail_index_record *rec,
-		       unsigned int seq, int notify);
+int index_expunge_mails(struct index_mailbox *ibox,
+			struct mail_index_record *first_rec,
+			struct mail_index_record *last_rec,
+			unsigned int first_seq, unsigned int last_seq,
+			int notify);
 
 void index_mailbox_check_add(struct index_mailbox *ibox, const char *path);
 void index_mailbox_check_remove_all(struct index_mailbox *ibox);



More information about the dovecot-cvs mailing list