changeset 3973:fec2e36ddb3b HEAD

And a few fixes
author Timo Sirainen <tss@iki.fi>
date Thu, 02 Feb 2006 23:00:32 +0200
parents a506ee4ec31e
children 10db5f23d3f0
files src/plugins/convert/convert-storage.c
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/convert/convert-storage.c	Thu Feb 02 22:42:44 2006 +0200
+++ b/src/plugins/convert/convert-storage.c	Thu Feb 02 23:00:32 2006 +0200
@@ -8,7 +8,7 @@
 
 #include <stdio.h>
 
-#define CONVERT_LOCK_FILENAME ".dovecot-convert.lock"
+#define CONVERT_LOCK_FILENAME ".dovecot.convert"
 
 const struct dotlock_settings dotlock_settings = {
 	NULL,
@@ -194,15 +194,27 @@
 		return -1;
 	}
 
+	/* just in case if another process just had converted the mailbox,
+	   reopen the source storage */
+	mail_storage_destroy(&source_storage);
+	source_storage = mail_storage_create_with_data(source_data, user,
+						       flags, lock_method);
+	if (source_storage == NULL) {
+		/* No need for conversion anymore. */
+		file_dotlock_delete(&dotlock);
+		return 0;
+	}
+
 	dest_storage = mail_storage_create_with_data(dest_data, user,
 						     flags, lock_method);
 	if (dest_storage == NULL) {
 		i_error("Mailbox conversion: Failed to create destination "
 			"storage with data: %s", dest_data);
+		ret = -1;
+	} else {
+		ret = mailbox_list_copy(source_storage, dest_storage);
 	}
 
-	ret = mailbox_list_copy(source_storage, dest_storage);
-
 	if (ret == 0) {
 		/* all finished. rename the source directory to mark the
 		   move as finished. FIXME: kind of kludgy way to get the
@@ -220,7 +232,9 @@
 		ret = 1;
 	}
 
+	file_dotlock_delete(&dotlock);
+	if (dest_storage != NULL)
+		mail_storage_destroy(&dest_storage);
 	mail_storage_destroy(&source_storage);
-	mail_storage_destroy(&dest_storage);
 	return ret;
 }