[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-expunge.c,1.30,1.31

cras at procontrol.fi cras at procontrol.fi
Sun Oct 5 21:45:48 EEST 2003


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

Modified Files:
	mbox-expunge.c 
Log Message:
mbox expunging works again



Index: mbox-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-expunge.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mbox-expunge.c	2 Sep 2003 22:33:34 -0000	1.30
+++ mbox-expunge.c	5 Oct 2003 17:45:46 -0000	1.31
@@ -63,8 +63,7 @@
 	uoff_t old_limit;
 	int failed;
 
-	i_assert(ctx->input->v_offset <= ctx->move_offset);
-	i_stream_skip(ctx->input, ctx->move_offset - ctx->input->v_offset);
+	i_stream_seek(ctx->input, ctx->move_offset);
 
 	if (ctx->output->offset == 0) {
 		/* we're writing to beginning of mbox, so we
@@ -120,20 +119,20 @@
 	return !failed;
 }
 
-static int get_from_offset(struct mail_index *index,
+static int get_from_offset(struct mbox_expunge_context *ctx,
 			   struct mail_index_record *rec, uoff_t *offset_r)
 {
-#if 0
-	uoff_t offset, hdr_size, body_size;
+	struct message_size hdr_size;
+	uoff_t offset, body_size;
 
-	if (!mbox_mail_get_location(index, rec, &offset,
-				    &hdr_size, &body_size))
+	if (!mbox_mail_get_location(ctx->ibox->index, rec, &offset, &body_size))
 		return FALSE;
 
-	*offset_r = offset + hdr_size + body_size;
+	i_stream_seek(ctx->input, offset);
+	message_get_header_size(ctx->input, &hdr_size, NULL);
+
+	*offset_r = offset + hdr_size.physical_size + body_size;
 	return TRUE;
-#endif
-	abort();
 }
 
 struct mail *mbox_storage_expunge_fetch_next(struct mail_expunge_context *_ctx)
@@ -149,7 +148,7 @@
 	if (mctx->fetch_next) {
                 mctx->fetch_next = FALSE;
 		do {
-			if (!get_from_offset(index, mctx->rec,
+			if (!get_from_offset(ctx, mctx->rec,
 					     &ctx->from_offset)) {
 				ctx->failed = TRUE;
 				return NULL;
@@ -176,7 +175,7 @@
 	else {
 		rec = ctx->ibox->index->lookup(ctx->ibox->index, seq-1);
 
-		if (!get_from_offset(ctx->ibox->index, rec, &ctx->from_offset))
+		if (!get_from_offset(ctx, rec, &ctx->from_offset))
 			return FALSE;
 	}
 
@@ -204,8 +203,7 @@
 			return FALSE;
 	}
 
-	if (!get_from_offset(ctx->ibox->index, imail->data.rec,
-			     &ctx->move_offset))
+	if (!get_from_offset(ctx, imail->data.rec, &ctx->move_offset))
 		return FALSE;
 
 	return index_storage_expunge(mail, ctx->ctx, seq_r, notify);



More information about the dovecot-cvs mailing list