[dovecot-cvs] dovecot/src/plugins/convert convert-storage.c, 1.1, 1.2

cras at dovecot.org cras at dovecot.org
Thu Feb 2 23:00:34 EET 2006


Update of /var/lib/cvs/dovecot/src/plugins/convert
In directory talvi:/tmp/cvs-serv19813

Modified Files:
	convert-storage.c 
Log Message:
And a few fixes



Index: convert-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/convert/convert-storage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- convert-storage.c	2 Feb 2006 20:42:44 -0000	1.1
+++ convert-storage.c	2 Feb 2006 21:00:32 -0000	1.2
@@ -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;
 }



More information about the dovecot-cvs mailing list