dsync-mailbox-tree-fill.c revision 63420a1d2cd229877426bce5eeb55aec5618b123
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "guid.h"
#include "str.h"
#include "mailbox-log.h"
#include "mail-namespace.h"
#include "mail-storage.h"
#include "mailbox-list-iter.h"
#include "dsync-mailbox-tree-private.h"
static int
const struct mailbox_info *info,
struct dsync_mailbox_node **node_r)
{
struct dsync_mailbox_node *node;
i_error("Mailbox '%s' exists in two namespaces: '%s' and '%s'",
return -1;
}
return 0;
}
static int
struct mailbox_metadata *metadata_r,
struct mailbox_status *status_r)
{
/* try the fast path */
return -1;
return -1;
if (status_r->uidvalidity != 0)
return 0;
/* no UIDVALIDITY assigned yet. syncing a mailbox should add it. */
if (mailbox_sync(box, 0) < 0)
return -1;
return -1;
return 0;
}
const struct mailbox_info *info)
{
struct dsync_mailbox_node *node;
struct mailbox_metadata metadata;
struct mailbox_status status;
const char *errstr;
enum mail_error error;
return 0;
return -1;
return 0;
/* get GUID and UIDVALIDITY for selectable mailbox */
switch (error) {
case MAIL_ERROR_NOTFOUND:
/* mailbox was just deleted? */
break;
case MAIL_ERROR_NOTPOSSIBLE:
/* invalid mbox files? ignore */
break;
default:
i_error("Failed to access mailbox %s: %s",
mailbox_free(&box);
return -1;
}
} else {
sizeof(node->mailbox_guid));
}
mailbox_free(&box);
return 0;
}
static struct dsync_mailbox_node *
{
struct dsync_mailbox_node *node;
}
static int
struct mail_namespace *ns)
{
struct dsync_mailbox_node *node;
struct dsync_mailbox_delete *del;
struct mailbox_log *log;
struct mailbox_log_iter *iter;
const struct mailbox_log_record *rec;
return 0;
/* mailbox still exists. maybe it was restored
from backup or something. */
break;
}
break;
/* directory exists again, skip it */
break;
}
/* we don't know what directory name was deleted,
just its hash. if the name still exists on the other
dsync side, it can match this deletion to the
name. */
break;
/* directory has been deleted again, skip it */
break;
}
/* notify the remote that we want to keep this
directory created (unless remote has a newer delete
timestamp) */
break;
break;
break;
}
}
if (mailbox_log_iter_deinit(&iter) < 0) {
i_error("Mailbox log iteration for namespace '%s' failed",
return -1;
}
return 0;
}
static int
struct dsync_mailbox_node *node1,
struct dsync_mailbox_node *node2)
{
struct mailbox_update update;
struct dsync_mailbox_node *change_node;
int ret = 0;
/* just in case the duplication exists in both sides,
make them choose the same node */
change_node = node1;
else
change_node = node2;
i_error("Duplicate mailbox GUID %s for mailboxes %s and %s - "
"giving a new GUID %s to %s",
i_error("Couldn't update mailbox %s GUID: %s",
ret = -1;
} else {
sizeof(change_node->mailbox_guid));
}
mailbox_free(&box);
return ret;
}
{
const enum mailbox_list_iter_flags list_flags =
/* FIXME: we'll skip symlinks, because we can't handle them
currently. in future we could detect them and create them
by creating the symlink. */
const enum mailbox_list_iter_flags subs_list_flags =
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
int ret = 0;
/* assign namespace to its root, so it gets copied to children */
if (ns->prefix_len > 0) {
} else {
}
/* first add all of the existing mailboxes */
ret = -1;
}
if (mailbox_list_iter_deinit(&iter) < 0) {
ret = -1;
}
/* add subscriptions */
ret = -1;
else
}
if (mailbox_list_iter_deinit(&iter) < 0) {
ret = -1;
}
if (ret < 0)
return -1;
&dup_node2) < 0) {
return -1;
}
/* add timestamps */
return -1;
return 0;
}