[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-expunge.c,1.11,1.12

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/maildir
In directory danu:/tmp/cvs-serv23230/lib-storage/index/maildir

Modified Files:
	maildir-expunge.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: maildir-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-expunge.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- maildir-expunge.c	18 May 2003 12:26:06 -0000	1.11
+++ maildir-expunge.c	21 Jul 2003 14:35:39 -0000	1.12
@@ -6,15 +6,19 @@
 
 int maildir_expunge_locked(struct index_mailbox *ibox, int notify)
 {
-	struct mail_index_record *rec;
-	unsigned int seq;
+	struct mail_index_record *rec, *first_rec, *last_rec;
+	unsigned int seq, first_seq, last_seq;
 	int ret, no_permission = FALSE;
 
 	if (!index_expunge_seek_first(ibox, &seq, &rec))
 		return FALSE;
 
+	first_rec = last_rec = NULL;
+	first_seq = last_seq = 0;
 	while (rec != NULL) {
-		if (rec->msg_flags & MAIL_DELETED) {
+		if ((rec->msg_flags & MAIL_DELETED) == 0)
+			ret = FALSE;
+		else {
 			t_push();
 			ret = maildir_expunge_mail(ibox->index, rec);
 			t_pop();
@@ -23,16 +27,34 @@
 				if (errno != EACCES)
 					return FALSE;
 				no_permission = TRUE;
-				seq++;
 			} else {
-				if (!index_expunge_mail(ibox, rec, seq, notify))
-					return FALSE;
+				if (first_rec == NULL) {
+					first_rec = rec;
+					first_seq = seq;
+				}
+				last_rec = rec;
+				last_seq = seq;
 			}
+		}
+
+		if (!ret && first_rec != NULL) {
+			if (!index_expunge_mails(ibox, first_rec, last_rec,
+						 first_seq, last_seq, notify))
+				return FALSE;
+			first_rec = NULL;
+
+			seq = first_seq;
+			rec = ibox->index->lookup(ibox->index, seq);
 		} else {
 			seq++;
+			rec = ibox->index->next(ibox->index, rec);
 		}
+	}
 
-		rec = ibox->index->next(ibox->index, rec);
+	if (first_rec != NULL) {
+		if (!index_expunge_mails(ibox, first_rec, last_rec,
+					 first_seq, last_seq, notify))
+			return FALSE;
 	}
 
 	if (no_permission) {



More information about the dovecot-cvs mailing list