changeset 12599:513e6e0b27ed

dsync: Changes to make it work with imapc storage.
author Timo Sirainen <tss@iki.fi>
date Mon, 24 Jan 2011 00:42:29 +0200
parents 360af3cc616b
children ba3c0ee558f5
files src/dsync/dsync-worker-local.c src/dsync/dsync.c
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/dsync/dsync-worker-local.c	Mon Jan 24 00:42:06 2011 +0200
+++ b/src/dsync/dsync-worker-local.c	Mon Jan 24 00:42:29 2011 +0200
@@ -1658,7 +1658,8 @@
 	i_assert(worker->save_input == NULL);
 
 	save_ctx = mailbox_save_alloc(worker->ext_mail->transaction);
-	mailbox_save_set_guid(save_ctx, msg->guid);
+	if (*msg->guid != '\0')
+		mailbox_save_set_guid(save_ctx, msg->guid);
 	local_worker_msg_save_set_metadata(worker, worker->mail->box,
 					   save_ctx, msg);
 	if (*data->pop3_uidl != '\0')
@@ -1753,7 +1754,10 @@
 		worker->get_mailbox = get->mailbox;
 
 		trans = mailbox_transaction_begin(box, 0);
-		worker->get_mail = mail_alloc(trans, 0, NULL);
+		worker->get_mail = mail_alloc(trans, MAIL_FETCH_UIDL_BACKEND |
+					      MAIL_FETCH_RECEIVED_DATE |
+					      MAIL_FETCH_STREAM_HEADER |
+					      MAIL_FETCH_STREAM_BODY, NULL);
 	}
 
 	if (!mail_set_uid(worker->get_mail, get->uid)) {
@@ -1764,15 +1768,17 @@
 
 	memset(&data, 0, sizeof(data));
 	if (mail_get_special(worker->get_mail, MAIL_FETCH_UIDL_BACKEND,
-			     &data.pop3_uidl) < 0 ||
-	    mail_get_received_date(worker->get_mail, &data.received_date) < 0 ||
+			     &data.pop3_uidl) < 0)
+		data.pop3_uidl = "";
+	else
+		data.pop3_uidl = t_strdup(data.pop3_uidl);
+	if (mail_get_received_date(worker->get_mail, &data.received_date) < 0 ||
 	    mail_get_stream(worker->get_mail, NULL, NULL, &data.input) < 0) {
 		get->callback(worker->get_mail->expunged ?
 			      DSYNC_MSG_GET_RESULT_EXPUNGED :
 			      DSYNC_MSG_GET_RESULT_FAILED, NULL, get->context);
 	} else {
 		worker->reading_mail = TRUE;
-		data.pop3_uidl = t_strdup(data.pop3_uidl);
 		data.input = i_stream_create_limit(data.input, (uoff_t)-1);
 		i_stream_set_destroy_callback(data.input,
 					      local_worker_msg_get_done,
--- a/src/dsync/dsync.c	Mon Jan 24 00:42:06 2011 +0200
+++ b/src/dsync/dsync.c	Mon Jan 24 00:42:29 2011 +0200
@@ -284,7 +284,8 @@
 					      MAILBOX_LIST_PATH_TYPE_MAILBOX);
 		path2 = mailbox_list_get_path(mail_user2->namespaces->list, NULL,
 					      MAILBOX_LIST_PATH_TYPE_MAILBOX);
-		if (strcmp(path1, path2) == 0) {
+		if (path1 != NULL && path2 != NULL &&
+		    strcmp(path1, path2) == 0) {
 			i_fatal("Both source and destination mail_location "
 				"points to same directory: %s", path1);
 		}