[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-sync-full.c, 1.4, 1.5

cras at dovecot.org cras at dovecot.org
Tue Apr 18 21:17:49 EEST 2006


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

Modified Files:
	dbox-sync-full.c 
Log Message:
Fixes



Index: dbox-sync-full.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-full.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dbox-sync-full.c	18 Apr 2006 14:49:40 -0000	1.4
+++ dbox-sync-full.c	18 Apr 2006 18:17:47 -0000	1.5
@@ -55,6 +55,7 @@
 	if (mbox->file->seeked_uid >= ctx->mail_index_next_uid) {
 		/* new mail. append it. */
 		mail_index_append(ctx->trans, mbox->file->seeked_uid, &seq);
+		*seq_r = 0;
 	} else {
 		if (mail_index_lookup_uid_range(ctx->sync_view,
 						mbox->file->seeked_uid,
@@ -72,6 +73,7 @@
 			mail_index_mark_corrupted(mbox->ibox.index);
 			return -1;
 		}
+		*seq_r = seq;
 	}
 
 	flags = 0;
@@ -104,7 +106,6 @@
 			      &mbox->file->file_seq, NULL);
 	mail_index_update_ext(ctx->trans, seq, mbox->dbox_offset_ext_idx,
 			      &hdr_offset, NULL);
-	*seq_r = seq;
 	return 0;
 }
 
@@ -142,12 +143,28 @@
 		if (dbox_sync_full_mail(ctx, &seq) < 0)
 			return -1;
 
-		seq_range_array_add(&entry.uid_list, 0, seq);
-		seq_range_array_add(&ctx->exists, 0, seq);
+		/* add to this file's uid list */
+		seq_range_array_add(&entry.uid_list, 0,
+				    ctx->mbox->file->seeked_uid);
+		if (seq != 0) {
+			/* add to the whole mailbox's exist list so we can
+			   expunge the mails that weren't found. seq=0 is
+			   given for newly appended mails */
+			seq_range_array_add(&ctx->exists, 0, seq);
+		}
 
 		ret = dbox_file_seek_next_nonexpunged(mbox);
 	}
-	dbox_uidlist_sync_append(ctx->uidlist_sync_ctx, &entry);
+	if (ret == 0 && array_count(&entry.uid_list) == 0) {
+		/* all mails expunged in the file */
+		if (unlink(mbox->file->path) < 0) {
+			mail_storage_set_critical(STORAGE(mbox->storage),
+				"unlink(%s) failed: %m", mbox->file->path);
+			return -1;
+		}
+	} else {
+		dbox_uidlist_sync_append(ctx->uidlist_sync_ctx, &entry);
+	}
 	return ret;
 }
 



More information about the dovecot-cvs mailing list