enum mailbox_existence existence;
int ret;
- if ((ret = mailbox_exists(box, &existence)) < 0) {
+ if ((ret = mailbox_exists(box, TRUE, &existence)) < 0) {
client_send_storage_error(cmd, mailbox_get_storage(box));
return FALSE;
}
box->index_prefix);
}
-int index_storage_mailbox_exists(struct mailbox *box,
+int index_storage_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
- return index_storage_mailbox_exists_full(box, NULL, existence_r);
+ return index_storage_mailbox_exists_full(box, auto_boxes,
+ NULL, existence_r);
}
-int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir,
+int index_storage_mailbox_exists_full(struct mailbox *box, bool auto_boxes,
+ const char *subdir,
enum mailbox_existence *existence_r)
{
struct stat st;
const char *path, *path2;
if (strcmp(box->name, "INBOX") == 0 &&
- (box->list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0) {
+ (box->list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0 &&
+ auto_boxes) {
/* INBOX always exists */
*existence_r = MAILBOX_EXISTENCE_SELECT;
return 0;
void index_storage_mailbox_alloc(struct mailbox *box, const char *vname,
enum mailbox_flags flags,
const char *index_prefix);
-int index_storage_mailbox_exists(struct mailbox *box,
+int index_storage_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r);
-int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir,
+int index_storage_mailbox_exists_full(struct mailbox *box, bool auto_boxes,
+ const char *subdir,
enum mailbox_existence *existence_r);
int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory);
int index_storage_mailbox_enable(struct mailbox *box,
return FALSE;
}
-static int maildir_mailbox_exists(struct mailbox *box,
+static int maildir_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
- return index_storage_mailbox_exists_full(box, "cur", existence_r);
+ return index_storage_mailbox_exists_full(box, auto_boxes,
+ "cur", existence_r);
}
static int maildir_mailbox_open(struct mailbox *box)
if (!MAILBOX_INFO_FLAGS_FINISHED(ctx->info.flags)) {
struct mailbox *box;
enum mailbox_existence existence;
+ bool auto_boxes =
+ (ctx->ctx.flags & MAILBOX_LIST_ITER_NO_AUTO_BOXES) == 0;
box = mailbox_alloc(ctx->ctx.list, list_path,
MAILBOX_FLAG_KEEP_RECENT);
- ret = mailbox_exists(box, &existence);
+ ret = mailbox_exists(box, auto_boxes, &existence);
mailbox_free(&box);
if (ret < 0) {
bool (*is_readonly)(struct mailbox *box);
int (*enable)(struct mailbox *box, enum mailbox_feature features);
- int (*exists)(struct mailbox *box, enum mailbox_existence *existence_r);
+ int (*exists)(struct mailbox *box, bool auto_boxes,
+ enum mailbox_existence *existence_r);
int (*open)(struct mailbox *box);
void (*close)(struct mailbox *box);
void (*free)(struct mailbox *box);
return FALSE;
}
-int mailbox_exists(struct mailbox *box, enum mailbox_existence *existence_r)
+int mailbox_exists(struct mailbox *box, bool auto_boxes,
+ enum mailbox_existence *existence_r)
{
if (!mailbox_list_is_valid_existing_name(box->list, box->name)) {
/* report it as not selectable, since it exists but we won't
return 0;
}
- return box->v.exists(box, existence_r);
+ return box->v.exists(box, auto_boxes, existence_r);
}
static int mailbox_check_mismatching_separators(struct mailbox *box)
with possibly different readonly-state. */
struct mailbox *mailbox_alloc(struct mailbox_list *list, const char *vname,
enum mailbox_flags flags);
-/* Get mailbox existence state */
-int mailbox_exists(struct mailbox *box, enum mailbox_existence *existence_r);
+/* Get mailbox existence state. If auto_boxes=FALSE, return
+ MAILBOX_EXISTENCE_NONE for autocreated mailboxes that haven't been
+ physically created yet */
+int mailbox_exists(struct mailbox *box, bool auto_boxes,
+ enum mailbox_existence *existence_r);
/* Open the mailbox. If this function isn't called explicitly, it's also called
internally by lib-storage when necessary. */
int mailbox_open(struct mailbox *box);
}
static int test_mailbox_exists(struct mailbox *box ATTR_UNUSED,
+ bool auto_boxes ATTR_UNUSED,
enum mailbox_existence *existence_r)
{
*existence_r = MAILBOX_EXISTENCE_SELECT;
return abox->module_ctx.super.transaction_commit(ctx, changes_r);
}
-static int acl_mailbox_exists(struct mailbox *box,
+static int acl_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
struct acl_mailbox *abox = ACL_CONTEXT(box);
if (strcmp(rights[i], MAIL_ACL_LOOKUP) == 0 ||
strcmp(rights[i], MAIL_ACL_READ) == 0 ||
strcmp(rights[i], MAIL_ACL_INSERT) == 0)
- return abox->module_ctx.super.exists(box, existence_r);
+ return abox->module_ctx.super.exists(box, auto_boxes,
+ existence_r);
}
*existence_r = MAILBOX_EXISTENCE_NONE;
return 0;
return ret;
}
-static int autocreate_mailbox_exists(struct mailbox *box,
+static int autocreate_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
union mailbox_module_context *abox = AUTOCREATE_CONTEXT(box);
- if (is_autocreated(box->storage->user, box->vname)) {
+ if (auto_boxes && is_autocreated(box->storage->user, box->vname)) {
*existence_r = MAILBOX_EXISTENCE_SELECT;
return 0;
}
- return abox->super.exists(box, existence_r);
+ return abox->super.exists(box, auto_boxes, existence_r);
}
static int
}
}
-static int virtual_mailbox_exists(struct mailbox *box,
+static int virtual_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
- return index_storage_mailbox_exists_full(box, VIRTUAL_CONFIG_FNAME,
+ return index_storage_mailbox_exists_full(box, auto_boxes,
+ VIRTUAL_CONFIG_FNAME,
existence_r);
}