[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-file.c, 1.12, 1.12.2.1 dbox-file.h, 1.2, 1.2.2.1 dbox-mail.c, 1.9.2.1, 1.9.2.2 dbox-save.c, 1.10.2.2, 1.10.2.3 dbox-storage.h, 1.10, 1.10.2.1 dbox-sync-expunge.c, 1.15, 1.15.2.1 dbox-sync-full.c, 1.5.2.1, 1.5.2.2 dbox-sync.c, 1.16.2.1, 1.16.2.2

cras at dovecot.org cras at dovecot.org
Mon Jun 12 11:24:06 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv13932

Modified Files:
      Tag: branch_1_0
	dbox-file.c dbox-file.h dbox-mail.c dbox-save.c dbox-storage.h 
	dbox-sync-expunge.c dbox-sync-full.c dbox-sync.c 
Log Message:
Allow reading saved mails which haven't been committed yet (ie. make quota
plugin work).



Index: dbox-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-file.c,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- dbox-file.c	12 Apr 2006 19:24:57 -0000	1.12
+++ dbox-file.c	12 Jun 2006 08:24:03 -0000	1.12.2.1
@@ -101,7 +101,8 @@
 	return 1;
 }
 
-int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset)
+int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset,
+		   bool ignore_zero_uid)
 {
 	int ret;
 
@@ -148,7 +149,8 @@
 	if ((ret = dbox_file_read_mail_header(mbox, mbox->file, offset)) <= 0)
 		return ret;
 
-	if (mbox->file->seeked_mail_size == 0 || mbox->file->seeked_uid == 0) {
+	if (mbox->file->seeked_mail_size == 0 ||
+	    (mbox->file->seeked_uid == 0 && !ignore_zero_uid)) {
 		/* could be legitimately just not written yet. we're at EOF. */
 		return 0;
 	}
@@ -166,7 +168,7 @@
 			mbox->file->mail_header_size +
 			mbox->file->seeked_mail_size;
 
-		ret = dbox_file_seek(mbox, mbox->file->file_seq, offset);
+		ret = dbox_file_seek(mbox, mbox->file->file_seq, offset, FALSE);
 		if (ret <= 0)
 			return ret;
 

Index: dbox-file.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-file.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- dbox-file.h	28 Jan 2006 22:05:48 -0000	1.2
+++ dbox-file.h	12 Jun 2006 08:24:03 -0000	1.2.2.1
@@ -13,8 +13,8 @@
 
 void dbox_file_close(struct dbox_file *file);
 /* Returns -1 = error, 0 = EOF (mail was just moved / file broken), 1 = ok */
-int dbox_file_seek(struct dbox_mailbox *mbox,
-		   uint32_t file_seq, uoff_t offset);
+int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset,
+		   bool ignore_zero_uid);
 int dbox_file_seek_next_nonexpunged(struct dbox_mailbox *mbox);
 
 void dbox_file_header_init(struct dbox_file_header *hdr);

Index: dbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-mail.c,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -d -r1.9.2.1 -r1.9.2.2
--- dbox-mail.c	10 May 2006 13:42:56 -0000	1.9.2.1
+++ dbox-mail.c	12 Jun 2006 08:24:03 -0000	1.9.2.2
@@ -77,6 +77,8 @@
 			       int *ret_r)
 {
 	struct dbox_mailbox *mbox = (struct dbox_mailbox *)mail->ibox;
+	struct dbox_transaction_context *t =
+		(struct dbox_transaction_context *)mail->trans;
 	uint32_t seq = mail->mail.mail.seq;
 
 	*ret_r = dbox_mail_lookup_offset(mail->trans, seq,
@@ -87,7 +89,8 @@
 		return TRUE;
 	}
 
-	if ((*ret_r = dbox_file_seek(mbox, *file_seq_r, *offset_r)) < 0)
+	if ((*ret_r = dbox_file_seek(mbox, *file_seq_r, *offset_r,
+				     seq >= t->first_saved_mail_seq)) < 0)
 		return TRUE;
 	if (*ret_r > 0) {
 		/* ok */

Index: dbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-save.c,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -d -r1.10.2.2 -r1.10.2.3
--- dbox-save.c	8 Jun 2006 18:21:12 -0000	1.10.2.2
+++ dbox-save.c	12 Jun 2006 08:24:03 -0000	1.10.2.3
@@ -22,7 +22,6 @@
 	struct mail_index_transaction *trans;
 	struct dbox_uidlist_append_ctx *append_ctx;
 
-	uint32_t first_append_seq;
 	struct mail_index_sync_ctx *index_sync_ctx;
 
 	/* updated for each appended mail: */
@@ -220,8 +219,8 @@
 			      mbox->dbox_offset_ext_idx, &ctx->hdr_offset,
 			      NULL);
 
-	if (ctx->first_append_seq == 0)
-		ctx->first_append_seq = ctx->seq;
+	if (t->first_saved_mail_seq == 0)
+		t->first_saved_mail_seq = ctx->seq;
 	t_pop();
 
 	*ctx_r = &ctx->ctx;
@@ -310,8 +309,8 @@
 
 int dbox_transaction_save_commit_pre(struct dbox_save_context *ctx)
 {
-	struct index_transaction_context *idx_trans =
-		(struct index_transaction_context *)ctx->ctx.transaction;
+	struct dbox_transaction_context *t =
+		(struct dbox_transaction_context *)ctx->ctx.transaction;
 	struct dbox_mail_header hdr;
 	struct dbox_file *file;
 	struct mail_index_view *view;
@@ -345,8 +344,8 @@
 	mail_index_append_assign_uids(ctx->trans, uid, &last_uid);
 
 	/* update UIDs */
-	for (seq = ctx->first_append_seq; seq <= ctx->seq; seq++, uid++) {
-		ret = dbox_mail_lookup_offset(idx_trans, seq,
+	for (seq = t->first_saved_mail_seq; seq <= ctx->seq; seq++, uid++) {
+		ret = dbox_mail_lookup_offset(&t->ictx, seq,
 					      &file_seq, &offset);
 		i_assert(ret > 0); /* it's in memory, shouldn't fail! */
 

Index: dbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.h,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- dbox-storage.h	12 Apr 2006 16:52:03 -0000	1.10
+++ dbox-storage.h	12 Jun 2006 08:24:03 -0000	1.10.2.1
@@ -70,6 +70,7 @@
 struct dbox_transaction_context {
 	struct index_transaction_context ictx;
 
+	uint32_t first_saved_mail_seq;
 	struct dbox_save_context *save_ctx;
 };
 

Index: dbox-sync-expunge.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-expunge.c,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -d -r1.15 -r1.15.2.1
--- dbox-sync-expunge.c	27 Apr 2006 12:33:21 -0000	1.15
+++ dbox-sync-expunge.c	12 Jun 2006 08:24:03 -0000	1.15.2.1
@@ -90,13 +90,13 @@
 	uoff_t full_size;
 	off_t bytes;
 
-	ret = dbox_file_seek(mbox, orig_entry->file_seq, orig_offset);
+	ret = dbox_file_seek(mbox, orig_entry->file_seq, orig_offset, FALSE);
 
 	if (ret >= 0 && mbox->file->hdr.have_expunged_mails != '0') {
 		/* there are some expunged mails in the file, go through all
 		   of the mails. */
 		ret = dbox_file_seek(mbox, orig_entry->file_seq,
-				     mbox->file->header_size);
+				     mbox->file->header_size, FALSE);
 	}
 
 	/* skip mails until we find the first we don't want expunged */
@@ -379,7 +379,7 @@
 	}
 
 	/* mails expunged from the end of file, ftruncate() it */
-	ret = dbox_file_seek(mbox, entry->file_seq, offset);
+	ret = dbox_file_seek(mbox, entry->file_seq, offset, FALSE);
 	if (ret <= 0) {
 		if (ret < 0)
 			return -1;

Index: dbox-sync-full.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-full.c,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -d -r1.5.2.1 -r1.5.2.2
--- dbox-sync-full.c	10 May 2006 13:42:56 -0000	1.5.2.1
+++ dbox-sync-full.c	12 Jun 2006 08:24:03 -0000	1.5.2.2
@@ -116,7 +116,7 @@
 	uint32_t seq;
 	int ret;
 
-	if ((ret = dbox_file_seek(mbox, file_seq, 0)) < 0) {
+	if ((ret = dbox_file_seek(mbox, file_seq, 0, FALSE)) < 0) {
 		/* error / broken file */
 		return -1;
 	}

Index: dbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync.c,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- dbox-sync.c	28 May 2006 19:25:55 -0000	1.16.2.1
+++ dbox-sync.c	12 Jun 2006 08:24:03 -0000	1.16.2.2
@@ -170,7 +170,7 @@
 		return -1;
 	}
 
-	if ((ret = dbox_file_seek(mbox, file_seq, offset)) <= 0)
+	if ((ret = dbox_file_seek(mbox, file_seq, offset, FALSE)) <= 0)
 		return ret;
 
 	while (mbox->file->seeked_uid <= uid2) {
@@ -257,7 +257,7 @@
 	unsigned char keyword_array, keyword_mask = 1;
 	unsigned int file_idx, first_flag_offset;
 
-	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0)
+	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0)
 		return -1;
 
 	keyword_array = set ? '1' : '0';
@@ -287,7 +287,7 @@
 	unsigned int first_flag_offset;
 	int ret;
 
-	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0)
+	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0)
 		return -1;
 
 	if (ctx->mbox->file->keyword_count == 0)
@@ -318,7 +318,7 @@
 	unsigned int count, file_idx, keyword_idx;
 	int ret = 0;
 
-	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0)
+	if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0)
 		return -1;
 
 	/* Get a list of all new keywords. Using seq_range is the easiest



More information about the dovecot-cvs mailing list