changeset 1024:2b7eaf2d31a1 HEAD

When save is aborted, remove the created temp files.
author Timo Sirainen <tss@iki.fi>
date Thu, 23 Jan 2003 05:34:00 +0200
parents dc660f588218
children eb80a942bd8b
files src/lib-storage/index/maildir/maildir-save.c
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c	Thu Jan 23 05:28:46 2003 +0200
+++ b/src/lib-storage/index/maildir/maildir-save.c	Thu Jan 23 05:34:00 2003 +0200
@@ -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();
 			}
 		}