[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-save.c,1.16,1.17

cras at procontrol.fi cras at procontrol.fi
Thu Jan 23 05:34:02 EET 2003


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

Modified Files:
	maildir-save.c 
Log Message:
When save is aborted, remove the created temp files.



Index: maildir-save.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- maildir-save.c	22 Jan 2003 19:23:28 -0000	1.16
+++ maildir-save.c	23 Jan 2003 03:34:00 -0000	1.17
@@ -213,10 +213,19 @@
 int maildir_storage_save_deinit(struct mail_save_context *ctx, int rollback)
 {
 	struct mail_filename *mf, *mf2;
-	const char *new_path;
+	const char *path;
 	int failed = FALSE;
 
-	if (!rollback) {
+	if (rollback) {
+		/* clean up the temp files */
+		for (mf = ctx->files; mf != NULL; mf = mf->next) {
+			t_push();
+			path = t_strconcat(ctx->tmpdir, "/", mf->dest, NULL);
+			(void)unlink(path);
+			t_pop();
+		}
+	} else {
+		/* move them into new/ */
 		for (mf = ctx->files; mf != NULL; mf = mf->next) {
 			if (!maildir_copy(ctx, mf->src, mf->dest)) {
 				failed = TRUE;
@@ -228,9 +237,9 @@
 			/* failed, try to unlink the mails already moved */
 			for (mf2 = ctx->files; mf2 != mf; mf2 = mf2->next) {
 				t_push();
-				new_path = t_strconcat(ctx->newdir, "/",
-						       mf2->dest, NULL);
-				(void)unlink(new_path);
+				path = t_strconcat(ctx->newdir, "/",
+						   mf2->dest, NULL);
+				(void)unlink(path);
 				t_pop();
 			}
 		}




More information about the dovecot-cvs mailing list