static int
rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,
- struct mail_namespace *ns, const char *name)
+ struct mail_namespace *ns, const char *vname)
{
struct mailbox *box;
struct mdbox_mailbox *mbox;
struct mail_index_transaction *trans;
struct dbox_sync_rebuild_context *rebuild_ctx;
enum mail_error error;
+ const char *name;
int ret;
+ name = mail_namespace_get_storage_name(ns, vname);
box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_READONLY |
MAILBOX_FLAG_KEEP_RECENT |
MAILBOX_FLAG_IGNORE_ACLS);
ctx->default_list = ns->list;
iter = mailbox_list_iter_init(ns->list, "*",
+ MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
#include "hostpid.h"
#include "eacces-error.h"
#include "mkdir-parents.h"
+#include "str.h"
#include "subscription-file.h"
#include "mailbox-list-delete.h"
#include "mailbox-list-maildir.h"
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
ARRAY_DEFINE(names_arr, const char *);
- const char *pattern, *oldpath, *newpath, *old_listname, *new_listname;
- const char *const *names;
- unsigned int i, count;
- size_t oldnamelen;
+ const char *pattern, *oldpath, *newpath, *old_childname, *new_childname;
+ const char *const *names, *old_vname, *new_vname;
+ unsigned int i, count, old_vnamelen;
pool_t pool;
- char old_sep;
+ string_t *str;
int ret;
ret = 0;
- oldnamelen = strlen(oldname);
/* first get the list of the children and save them to memory, because
we can't rely on readdir() not skipping files while the directory
pool = pool_alloconly_create("Maildir++ children list", 1024);
i_array_init(&names_arr, 64);
- old_sep = mailbox_list_get_hierarchy_sep(oldlist);
- pattern = t_strdup_printf("%s%c*", oldname, old_sep);
+ str = t_str_new(256);
+ old_vname = t_strdup(mail_namespace_get_vname(oldlist->ns, str, oldname));
+ old_vnamelen = strlen(oldname);
+
+ str_truncate(str, 0);
+ new_vname = t_strdup(mail_namespace_get_vname(newlist->ns, str, newname));
+
+ pattern = t_strdup_printf("%s%c*", old_vname, oldlist->ns->sep);
iter = mailbox_list_iter_init(oldlist, pattern,
+ MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS |
MAILBOX_LIST_ITER_RAW_LIST);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
/* verify that the prefix matches, otherwise we could have
problems with mailbox names containing '%' and '*' chars */
- if (strncmp(info->name, oldname, oldnamelen) == 0 &&
- info->name[oldnamelen] == old_sep) {
- name = p_strdup(pool, info->name + oldnamelen);
+ if (strncmp(info->name, old_vname, old_vnamelen) == 0 &&
+ info->name[old_vnamelen] == oldlist->ns->sep) {
+ name = p_strdup(pool, info->name + old_vnamelen);
array_append(&names_arr, &name, 1);
}
}
}
for (i = 0; i < count; i++) {
- old_listname = t_strconcat(oldname, names[i], NULL);
- if (strcmp(old_listname, newname) == 0) {
+ old_childname = mail_namespace_get_storage_name(oldlist->ns,
+ t_strconcat(old_vname, names[i], NULL));
+ if (strcmp(old_childname, new_vname) == 0) {
/* When doing RENAME "a" "a.b" we see "a.b" here.
We don't want to rename it anymore to "a.b.b". */
continue;
}
- new_listname = t_strconcat(newname, names[i], NULL);
- oldpath = mailbox_list_get_path(oldlist, old_listname,
+ new_childname = mail_namespace_get_storage_name(newlist->ns,
+ t_strconcat(new_vname, names[i], NULL));
+ oldpath = mailbox_list_get_path(oldlist, old_childname,
MAILBOX_LIST_PATH_TYPE_MAILBOX);
- newpath = mailbox_list_get_path(newlist, new_listname,
+ newpath = mailbox_list_get_path(newlist, new_childname,
MAILBOX_LIST_PATH_TYPE_MAILBOX);
/* FIXME: it's possible to merge two mailboxes if either one of
break;
}
- (void)rename_dir(oldlist, old_listname, newlist, new_listname,
+ (void)rename_dir(oldlist, old_childname, newlist, new_childname,
MAILBOX_LIST_PATH_TYPE_CONTROL);
- (void)rename_dir(oldlist, old_listname, newlist, new_listname,
+ (void)rename_dir(oldlist, old_childname, newlist, new_childname,
MAILBOX_LIST_PATH_TYPE_INDEX);
}
array_free(&names_arr);
static int
acllist_append(struct acl_backend_vfile *backend, struct ostream *output,
- const char *name)
+ const char *vname)
{
struct acl_object *aclobj;
struct acl_object_list_iter *iter;
struct acl_rights rights;
struct acl_backend_vfile_acllist acllist;
+ const char *name;
int ret;
+ name = mail_namespace_get_storage_name(backend->backend.list->ns,
+ vname);
acl_cache_flush(backend->backend.cache, name);
aclobj = acl_object_init_from_name(&backend->backend, name);
acllist_clear(backend, 0);
backend->rebuilding_acllist = TRUE;
- iter = mailbox_list_iter_init(list, "*", MAILBOX_LIST_ITER_RAW_LIST |
+ iter = mailbox_list_iter_init(list, "*",
+ MAILBOX_LIST_ITER_VIRTUAL_NAMES |
+ MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if (acllist_append(backend, output, info->name) < 0) {