dsync-mailbox-tree-fill.c revision 4aefbee3c3095f418a5f979031d54d3a25d6d37a
/* Copyright (c) 2012 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;
}
{
const enum mailbox_list_iter_flags list_flags =
const enum mailbox_list_iter_flags subs_list_flags =
struct mailbox_list_iterate_context *iter;
struct dsync_mailbox_node *node;
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 (dsync_mailbox_tree_build_guid_hash(tree) < 0)
ret = -1;
/* add timestamps */
ret = -1;
return ret;
}