dovecot-2.0: dbox: Moved more mailbox creation code to dbox-common.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 6 23:41:37 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/bdb1ea37ccee
changeset: 10652:bdb1ea37ccee
user: Timo Sirainen <tss at iki.fi>
date: Sat Feb 06 23:41:33 2010 +0200
description:
dbox: Moved more mailbox creation code to dbox-common.
diffstat:
3 files changed, 35 insertions(+), 47 deletions(-)
src/lib-storage/index/dbox-common/dbox-storage.c | 32 +++++++++++++++++----
src/lib-storage/index/dbox-multi/mdbox-storage.c | 25 ++--------------
src/lib-storage/index/dbox-single/sdbox-storage.c | 25 ++--------------
diffs (139 lines):
diff -r b1597605c3ef -r bdb1ea37ccee src/lib-storage/index/dbox-common/dbox-storage.c
--- a/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 06 23:22:15 2010 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-storage.c Sat Feb 06 23:41:33 2010 +0200
@@ -75,10 +75,33 @@ dbox_cleanup_if_exists(struct mailbox_li
return TRUE;
}
+static int dbox_mailbox_create_indexes(struct mailbox *box,
+ const struct mailbox_update *update)
+{
+ struct dbox_storage *storage = (struct dbox_storage *)box->storage;
+ const char *origin;
+ mode_t mode;
+ gid_t gid;
+
+ mailbox_list_get_dir_permissions(box->list, NULL, &mode, &gid, &origin);
+ if (mkdir_parents_chgrp(box->path, mode, gid, origin) == 0) {
+ /* create indexes immediately with the dbox header */
+ if (index_storage_mailbox_open(box) < 0)
+ return -1;
+ if (storage->v.mailbox_create_indexes(box, update) < 0)
+ return -1;
+ } else if (errno != EEXIST) {
+ if (!mail_storage_set_error_from_errno(box->storage)) {
+ mail_storage_set_critical(box->storage,
+ "mkdir(%s) failed: %m", box->path);
+ }
+ return -1;
+ }
+ return 0;
+}
+
int dbox_mailbox_open(struct mailbox *box)
{
- struct dbox_storage *storage = (struct dbox_storage *)box->storage;
-
if (box->input != NULL) {
mail_storage_set_critical(box->storage,
"dbox doesn't support streamed mailboxes");
@@ -91,7 +114,7 @@ int dbox_mailbox_open(struct mailbox *bo
if (strcmp(box->name, "INBOX") == 0 &&
(box->list->ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
/* INBOX always exists, create it */
- if (storage->v.mailbox_create_indexes(box, NULL) < 0)
+ if (dbox_mailbox_create_indexes(box, NULL) < 0)
return -1;
return box->opened ? 0 :
index_storage_mailbox_open(box);
@@ -134,7 +157,6 @@ int dbox_mailbox_create(struct mailbox *
int dbox_mailbox_create(struct mailbox *box,
const struct mailbox_update *update, bool directory)
{
- struct dbox_storage *storage = (struct dbox_storage *)box->storage;
const char *path, *alt_path, *origin;
struct stat st;
@@ -176,7 +198,7 @@ int dbox_mailbox_create(struct mailbox *
return -1;
}
- return storage->v.mailbox_create_indexes(box, update);
+ return dbox_mailbox_create_indexes(box, update);
}
int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx ATTR_UNUSED,
diff -r b1597605c3ef -r bdb1ea37ccee src/lib-storage/index/dbox-multi/mdbox-storage.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Sat Feb 06 23:22:15 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Sat Feb 06 23:41:33 2010 +0200
@@ -245,29 +245,12 @@ static int mdbox_mailbox_create_indexes(
const struct mailbox_update *update)
{
struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)box;
- const char *origin;
- mode_t mode;
- gid_t gid;
int ret;
- mailbox_list_get_dir_permissions(box->list, NULL, &mode, &gid, &origin);
- if (mkdir_parents_chgrp(box->path, mode, gid, origin) == 0) {
- /* create indexes immediately with the dbox header */
- if (index_storage_mailbox_open(box) < 0)
- return -1;
- mbox->creating = TRUE;
- ret = mdbox_write_index_header(box, update);
- mbox->creating = FALSE;
- if (ret < 0)
- return -1;
- } else if (errno != EEXIST) {
- if (!mail_storage_set_error_from_errno(box->storage)) {
- mail_storage_set_critical(box->storage,
- "mkdir(%s) failed: %m", box->path);
- }
- return -1;
- }
- return 0;
+ mbox->creating = TRUE;
+ ret = mdbox_write_index_header(box, update);
+ mbox->creating = FALSE;
+ return ret;
}
static void mdbox_storage_get_status_guid(struct mailbox *box,
diff -r b1597605c3ef -r bdb1ea37ccee src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c Sat Feb 06 23:22:15 2010 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Sat Feb 06 23:41:33 2010 +0200
@@ -183,29 +183,12 @@ static int sdbox_mailbox_create_indexes(
const struct mailbox_update *update)
{
struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)box;
- const char *origin;
- mode_t mode;
- gid_t gid;
int ret;
- mailbox_list_get_dir_permissions(box->list, NULL, &mode, &gid, &origin);
- if (mkdir_parents_chgrp(box->path, mode, gid, origin) == 0) {
- /* create indexes immediately with the dbox header */
- if (index_storage_mailbox_open(box) < 0)
- return -1;
- mbox->creating = TRUE;
- ret = sdbox_write_index_header(box, update);
- mbox->creating = FALSE;
- if (ret < 0)
- return -1;
- } else if (errno != EEXIST) {
- if (!mail_storage_set_error_from_errno(box->storage)) {
- mail_storage_set_critical(box->storage,
- "mkdir(%s) failed: %m", box->path);
- }
- return -1;
- }
- return 0;
+ mbox->creating = TRUE;
+ ret = sdbox_write_index_header(box, update);
+ mbox->creating = FALSE;
+ return ret;
}
static void sdbox_storage_get_status_guid(struct mailbox *box,
More information about the dovecot-cvs
mailing list