/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mail-storage.h"
#include "mail-namespace.h"
#include "doveadm-print.h"
#include "doveadm-mailbox-list-iter.h"
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"
#include <stdio.h>
struct copy_cmd_context {
const char *source_username;
const char *destname;
bool move;
};
static int
const struct mailbox_info *info)
{
return -1;
/* use a separately committed transaction for each mailbox.
this guarantees that mails aren't expunged without actually having
been copied. */
__func__);
else
if (ret2 < 0) {
i_error("%s message UID %u from '%s' failed: %s",
ret = -1;
}
}
if (mailbox_transaction_commit(&desttrans) < 0) {
i_error("Committing %s mails failed: %s",
/* rollback expunges */
ret = -1;
} else {
if (doveadm_mail_iter_deinit_sync(&iter) < 0)
ret = -1;
}
return ret;
}
static void
{
const char *error;
&ctx->source_user,
&error) < 0)
}
static int
{
int ret = 0;
if (mailbox_open(destbox) < 0) {
return -1;
}
ret = -1;
} T_END;
if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
if (mailbox_sync(destbox, 0) < 0) {
ret = -1;
}
return ret;
}
const char *const args[])
{
args++;
if ((_ctx->service_flags &
i_fatal("Use -u parameter to specify destination user");
args += 2;
}
}
{
}
}
{
}
{
}
.name = "copy",
};
.name = "move",
};