static int
dsync_mailbox_tree_add_node(struct dsync_mailbox_tree *tree,
const struct mailbox_info *info,
+ struct event *event,
struct dsync_mailbox_node **node_r)
{
struct dsync_mailbox_node *node;
i_assert(tree->root.ns == NULL);
node->ns = info->ns;
} else {
- i_error("Mailbox '%s' exists in two namespaces: '%s' and '%s'",
+ e_error(event,
+ "Mailbox '%s' exists in two namespaces: '%s' and '%s'",
info->vname, node->ns->prefix, info->ns->prefix);
return -1;
}
dsync_mailbox_tree_add_exists_node(struct dsync_mailbox_tree *tree,
const struct mailbox_info *info,
struct dsync_mailbox_node **node_r,
+ struct event *event,
enum mail_error *error_r)
{
- if (dsync_mailbox_tree_add_node(tree, info, node_r) < 0) {
+ if (dsync_mailbox_tree_add_node(tree, info, event, node_r) < 0) {
*error_r = MAIL_ERROR_TEMP;
return -1;
}
static int dsync_mailbox_tree_add(struct dsync_mailbox_tree *tree,
const struct mailbox_info *info,
const guid_128_t box_guid,
+ struct event *event,
enum mail_error *error_r)
{
struct dsync_mailbox_node *node;
return 0;
if ((info->flags & MAILBOX_NOSELECT) != 0) {
return !guid_128_is_empty(box_guid) ? 0 :
- dsync_mailbox_tree_add_exists_node(tree, info, &node, error_r);
+ dsync_mailbox_tree_add_exists_node(
+ tree, info, &node, event, error_r);
}
/* get GUID and UIDVALIDITY for selectable mailbox */
/* invalid mbox files? ignore */
break;
default:
- i_error("Failed to access mailbox %s: %s",
+ e_error(event, "Failed to access mailbox %s: %s",
info->vname, errstr);
*error_r = error;
ret = -1;
/* unwanted mailbox */
return 0;
}
- if (dsync_mailbox_tree_add_exists_node(tree, info, &node, error_r) < 0)
+ if (dsync_mailbox_tree_add_exists_node(
+ tree, info, &node, event, error_r) < 0)
return -1;
memcpy(node->mailbox_guid, metadata.guid,
sizeof(node->mailbox_guid));
static int
dsync_mailbox_tree_add_change_timestamps(struct dsync_mailbox_tree *tree,
- struct mail_namespace *ns)
+ struct mail_namespace *ns,
+ struct event *event)
{
struct dsync_mailbox_node *node;
struct dsync_mailbox_delete *del;
}
}
if (mailbox_log_iter_deinit(&iter) < 0) {
- i_error("Mailbox log iteration for namespace '%s' failed",
+ e_error(event, "Mailbox log iteration for namespace '%s' failed",
ns->prefix);
return -1;
}
static int
dsync_mailbox_tree_fix_guid_duplicate(struct dsync_mailbox_tree *tree,
struct dsync_mailbox_node *node1,
- struct dsync_mailbox_node *node2)
+ struct dsync_mailbox_node *node2,
+ struct event *event)
{
struct mailbox *box;
struct mailbox_update update;
change_node = node2;
change_vname = dsync_mailbox_node_get_full_name(tree, change_node);
- i_error("Duplicate mailbox GUID %s for mailboxes %s and %s - "
+ e_error(event, "Duplicate mailbox GUID %s for mailboxes %s and %s - "
"giving a new GUID %s to %s",
guid_128_to_string(node1->mailbox_guid),
dsync_mailbox_node_get_full_name(tree, node1),
i_assert(node1->ns != NULL && node2->ns != NULL);
box = mailbox_alloc(change_node->ns->list, change_vname, 0);
if (mailbox_update(box, &update) < 0) {
- i_error("Couldn't update mailbox %s GUID: %s",
+ e_error(event, "Couldn't update mailbox %s GUID: %s",
change_vname, mailbox_get_last_internal_error(box, NULL));
ret = -1;
} else {
struct mail_namespace *ns, const char *box_name,
const guid_128_t box_guid,
const char *const *exclude_mailboxes,
+ struct event *event,
enum mail_error *error_r)
{
const enum mailbox_list_iter_flags list_flags =
.vname = vname,
.ns = ns,
};
- if (dsync_mailbox_tree_add(tree, &ns_info, box_guid, error_r) < 0)
+ if (dsync_mailbox_tree_add(
+ tree, &ns_info, box_guid, event, error_r) < 0)
return -1;
} else {
tree->root.ns = ns;
while ((info = mailbox_list_iter_next(iter)) != NULL) T_BEGIN {
if (dsync_mailbox_info_is_wanted(info, box_name,
exclude_mailboxes)) {
- if (dsync_mailbox_tree_add(tree, info, box_guid, error_r) < 0)
+ if (dsync_mailbox_tree_add(
+ tree, info, box_guid, event, error_r) < 0)
ret = -1;
}
} T_END;
if (mailbox_list_iter_deinit(&iter) < 0) {
- i_error("Mailbox listing for namespace '%s' failed: %s",
+ e_error(event, "Mailbox listing for namespace '%s' failed: %s",
ns->prefix, mailbox_list_get_last_internal_error(ns->list, error_r));
ret = -1;
}
/* add subscriptions */
iter = mailbox_list_iter_init(ns->list, list_pattern, subs_list_flags);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
- if (dsync_mailbox_tree_add_node(tree, info, &node) == 0)
+ if (dsync_mailbox_tree_add_node(tree, info, event, &node) == 0)
node->subscribed = TRUE;
else {
*error_r = MAIL_ERROR_TEMP;
}
}
if (mailbox_list_iter_deinit(&iter) < 0) {
- i_error("Mailbox listing for namespace '%s' failed: %s",
+ e_error(event, "Mailbox listing for namespace '%s' failed: %s",
ns->prefix, mailbox_list_get_last_internal_error(ns->list, error_r));
ret = -1;
}
while (dsync_mailbox_tree_build_guid_hash(tree, &dup_node1,
&dup_node2) < 0) {
- if (dsync_mailbox_tree_fix_guid_duplicate(tree, dup_node1, dup_node2) < 0)
+ if (dsync_mailbox_tree_fix_guid_duplicate(
+ tree, dup_node1, dup_node2, event) < 0)
return -1;
}
/* add timestamps */
- if (dsync_mailbox_tree_add_change_timestamps(tree, ns) < 0)
+ if (dsync_mailbox_tree_add_change_timestamps(tree, ns, event) < 0)
return -1;
return 0;
}