dsync-mailbox-tree-fill.c revision 46a9a338c4b1d5ccc23f22acaa17393fa5263975
/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "guid.h"
#include "str.h"
#include "wildcard-match.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
const struct mailbox_info *info,
struct dsync_mailbox_node **node_r)
{
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,
const guid_128_t box_guid)
{
struct dsync_mailbox_node *node;
struct mailbox_metadata metadata;
struct mailbox_status status;
const char *errstr;
enum mail_error error;
int ret = 0;
return 0;
return !guid_128_is_empty(box_guid) ? 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",
ret = -1;
}
mailbox_free(&box);
return ret;
}
mailbox_free(&box);
if (!guid_128_is_empty(box_guid) &&
/* unwanted mailbox */
return 0;
}
return -1;
sizeof(node->mailbox_guid));
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;
break;
}
/* The mailbox is already deleted, but it may still
exist on the other side (even the subscription
alone). */
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;
const char *change_vname;
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;
}
static bool
const char *box_name,
const char *const *exclude_mailboxes)
{
const char *const *info_specialuses;
unsigned int i;
if (exclude_mailboxes == NULL &&
return TRUE;
/* include */
if (info_specialuses == NULL ||
return FALSE;
}
/* exclude */
if (exclude_mailboxes == NULL)
return TRUE;
for (i = 0; exclude_mailboxes[i] != NULL; i++) {
const char *exclude = exclude_mailboxes[i];
if (exclude[0] == '\\') {
/* special-use */
if (info_specialuses != NULL &&
return FALSE;
} else {
/* mailbox with wildcards */
return FALSE;
}
}
return TRUE;
}
const guid_128_t box_guid,
const char *const *exclude_mailboxes)
{
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;
const char *list_pattern =
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;
}
} T_END;
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;
}