convert-storage.c revision 8ecbb74bc4c7f6f6145da3525941d1d0e20e67f1
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "file-dotlock.h"
#include "index-storage.h"
#include "mail-search.h"
#include "convert-storage.h"
#include <stdio.h>
#define CONVERT_LOCK_FILENAME ".dovecot.convert"
const struct dotlock_settings dotlock_settings = {
};
{
struct mailbox_sync_context *ctx;
struct mailbox_sync_rec sync_rec;
struct mailbox_status status;
;
}
{
struct mail_search_context *ctx;
struct mail_search_arg search_arg;
int ret = 0;
if (sync_mailbox(srcbox) < 0)
return -1;
struct mail_keywords *keywords;
const char *const *keywords_list;
if (ret < 0)
break;
}
if (mailbox_search_deinit(&ctx) < 0)
ret = -1;
if (ret < 0)
else
/* source transaction committing isn't all that important.
ignore if it fails. */
if (ret < 0)
else
(void)mailbox_transaction_commit(&src_trans, 0);
return ret;
}
struct mail_storage *dest_storage,
struct mailbox_list *list)
{
int ret = 0;
return 0;
i_error("Mailbox conversion: Couldn't create mailbox "
return -1;
}
return 0;
}
/* It's a real mailbox. First create the destination mailbox. */
i_error("Mailbox conversion: Couldn't create mailbox %s",
return -1;
}
/* Open both the mailboxes.. */
i_error("Mailbox conversion: Couldn't open source mailbox %s",
return -1;
}
i_error("Mailbox conversion: Couldn't open dest mailbox %s",
return -1;
}
i_error("Mailbox conversion: Couldn't copy mailbox %s",
}
return ret;
}
struct mail_storage *dest_storage)
{
struct mailbox_list_context *iter;
struct mailbox_list *list;
int ret = 0;
list) < 0) {
ret = -1;
break;
}
}
if (mail_storage_mailbox_list_deinit(&iter) < 0)
ret = -1;
return ret;
}
const char *source_data, const char *dest_data)
{
enum mail_storage_flags flags;
const char *path;
int ret;
flags, lock_method);
if (source_storage == NULL) {
/* No need for conversion. */
return 0;
}
if (ret <= 0) {
if (ret == 0)
i_error("Mailbox conversion: Lock creation timeouted");
return -1;
}
/* just in case if another process just had converted the mailbox,
reopen the source storage */
flags, lock_method);
if (source_storage == NULL) {
/* No need for conversion anymore. */
return 0;
}
flags, lock_method);
if (dest_storage == NULL) {
i_error("Mailbox conversion: Failed to create destination "
"storage with data: %s", dest_data);
ret = -1;
} else {
}
if (ret == 0) {
/* all finished. rename the source directory to mark the
move as finished. FIXME: kind of kludgy way to get the
directory.. */
struct index_storage *index_storage =
(struct index_storage *)source_storage;
const char *dest;
i_error("Mailbox conversion: rename(%s, %s) failed: %m",
/* return success anyway */
}
ret = 1;
}
if (dest_storage != NULL)
return ret;
}