]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added auto_boxes parameter to mailbox_exists().
authorTimo Sirainen <tss@iki.fi>
Fri, 29 Jul 2011 11:29:01 +0000 (14:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 29 Jul 2011 11:29:01 +0000 (14:29 +0300)
12 files changed:
src/imap/cmd-subscribe.c
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h
src/lib-storage/test-mailbox.c
src/plugins/acl/acl-mailbox.c
src/plugins/autocreate/autocreate-plugin.c
src/plugins/virtual/virtual-storage.c

index f8a38221bbd3ed822e773f7ebdd3903f759902b5..92856810b3e1d2c749da275bc33d1a2797116b9d 100644 (file)
@@ -11,7 +11,7 @@ subscribe_is_valid_name(struct client_command_context *cmd, struct mailbox *box)
        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;
        }
index 46defead1e4848bc6ea063ce1cd8272e4cf7389c..fb129818ec8cb6af0adcd49a3a5255b9aa43e92d 100644 (file)
@@ -151,20 +151,23 @@ index_mailbox_alloc_index(struct mailbox *box)
                                          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;
index 54795086491ae006bfbc3a3b6478b438e1b1ba05..08d8078760b592ee76b1dc5185a153c704148dee 100644 (file)
@@ -57,9 +57,10 @@ void index_storage_lock_notify_reset(struct mailbox *box);
 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,
index 10f6d27a88c011b4e632ca720eeaa7b0d945e90a..2aacedbd651a1155b4cd2f987596a02fceed861f 100644 (file)
@@ -323,10 +323,11 @@ static bool maildir_storage_is_readonly(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)
index cf4a3903992c120df784dc4be25f352cedfb0ada..ea4087f88f89320e9fa15ba9408d57a31a81459a 100644 (file)
@@ -563,10 +563,12 @@ list_file(struct fs_list_iterate_context *ctx,
        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) {
index b2479b4d8942cb66ebfc53aa419a4ef862a104a3..66206dfe1b318d8f169332a8c7338312a83e0430 100644 (file)
@@ -107,7 +107,8 @@ struct mailbox_vfuncs {
        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);
index dcf9859f9255bcd426a72223c1d79b8043c69447..4d5b04e6ea820e6c6f8b94ab31b22ec61a4dcd8f 100644 (file)
@@ -622,7 +622,8 @@ static bool have_listable_namespace_prefix(struct mail_namespace *ns,
        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
@@ -638,7 +639,7 @@ int mailbox_exists(struct mailbox *box, enum mailbox_existence *existence_r)
                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)
index b0dc32397056f681c85dfcd00e4981ddf4bdf124..bfd98f75fb475291c00537cf0e0285cc3ae481e6 100644 (file)
@@ -365,8 +365,11 @@ bool mail_storage_is_mailbox_file(struct mail_storage *storage) ATTR_PURE;
    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);
index 302abe172e5f83a974d2db6f1db252cec579b613..76ae44d4f3a96492bcb539093f22b3302e76023a 100644 (file)
@@ -21,6 +21,7 @@ static int test_mailbox_enable(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;
index 0ded8b9b64b6faaffabe0fdc01a2a8b71c94f1c6..0bf5c8d1493b63af647353b3dc09d599f7c6f1ac 100644 (file)
@@ -412,7 +412,7 @@ acl_transaction_commit(struct mailbox_transaction_context *ctx,
        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);
@@ -432,7 +432,8 @@ static int acl_mailbox_exists(struct mailbox *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;
index 309b02512932daffca24a98e4cc63ecafc7fa6ee..1c1b108b1d49a8188ba91dc017d50818646c05fb 100644 (file)
@@ -133,17 +133,17 @@ static int autocreate_mailbox_open(struct mailbox *box)
        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
index a64b3c477e19659bc1c1fd4fdcba4415b3bf52ba..6cf3c8cdfc66e03c111c403963435f1b798913c5 100644 (file)
@@ -259,10 +259,11 @@ static void virtual_mailbox_close_internal(struct virtual_mailbox *mbox)
        }
 }
 
-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);
 }