dovecot-2.0: mdbox: If :INDEX=path is specified, keep storage in...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 20 17:30:53 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/012a1773ebfd
changeset: 12135:012a1773ebfd
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 20 15:30:07 2010 +0100
description:
mdbox: If :INDEX=path is specified, keep storage indexes there also.
diffstat:
src/lib-storage/index/dbox-multi/mdbox-map-private.h | 2 +-
src/lib-storage/index/dbox-multi/mdbox-map.c | 35 ++++++++++++++---
src/lib-storage/index/dbox-multi/mdbox-map.h | 3 +-
src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 +-
4 files changed, 32 insertions(+), 11 deletions(-)
diffs (112 lines):
diff -r b44b8ba23c5c -r 012a1773ebfd src/lib-storage/index/dbox-multi/mdbox-map-private.h
--- a/src/lib-storage/index/dbox-multi/mdbox-map-private.h Fri Sep 17 20:20:53 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-map-private.h Mon Sep 20 15:30:07 2010 +0100
@@ -12,7 +12,7 @@
struct mdbox_map {
struct mdbox_storage *storage;
const struct mdbox_settings *set;
- char *path;
+ char *path, *index_path;
struct mail_index *index;
struct mail_index_view *view;
diff -r b44b8ba23c5c -r 012a1773ebfd src/lib-storage/index/dbox-multi/mdbox-map.c
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Sep 17 20:20:53 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Mon Sep 20 15:30:07 2010 +0100
@@ -46,16 +46,24 @@
}
struct mdbox_map *
-mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list,
- const char *path)
+mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list)
{
struct mdbox_map *map;
+ const char *root, *index_root;
+
+ root = mailbox_list_get_path(root_list, NULL,
+ MAILBOX_LIST_PATH_TYPE_DIR);
+ index_root = mailbox_list_get_path(root_list, NULL,
+ MAILBOX_LIST_PATH_TYPE_INDEX);
map = i_new(struct mdbox_map, 1);
map->storage = storage;
map->set = storage->set;
- map->path = i_strdup(path);
- map->index = mail_index_alloc(path, MDBOX_GLOBAL_INDEX_PREFIX);
+ map->path = i_strconcat(root, "/"MDBOX_GLOBAL_DIR_NAME, NULL);
+ map->index_path =
+ i_strconcat(index_root, "/"MDBOX_GLOBAL_DIR_NAME, NULL);
+ map->index = mail_index_alloc(map->index_path,
+ MDBOX_GLOBAL_INDEX_PREFIX);
mail_index_set_fsync_mode(map->index,
MAP_STORAGE(map)->set->parsed_fsync_mode, 0);
mail_index_set_lock_method(map->index,
@@ -87,18 +95,19 @@
mail_index_close(map->index);
}
mail_index_free(&map->index);
+ i_free(map->index_path);
i_free(map->path);
i_free(map);
}
-static int mdbox_map_mkdir_storage(struct mdbox_map *map)
+static int mdbox_map_mkdir_storage_path(struct mdbox_map *map, const char *path)
{
struct stat st;
- if (stat(map->path, &st) == 0)
+ if (stat(path, &st) == 0)
return 0;
- if (mailbox_list_mkdir(map->root_list, map->path,
+ if (mailbox_list_mkdir(map->root_list, path,
MAILBOX_LIST_PATH_TYPE_DIR) < 0) {
mail_storage_copy_list_error(MAP_STORAGE(map), map->root_list);
return -1;
@@ -106,6 +115,18 @@
return 0;
}
+static int mdbox_map_mkdir_storage(struct mdbox_map *map)
+{
+ if (mdbox_map_mkdir_storage_path(map, map->path) < 0)
+ return -1;
+
+ if (strcmp(map->path, map->index_path) != 0) {
+ if (mdbox_map_mkdir_storage_path(map, map->index_path) < 0)
+ return -1;
+ }
+ return 0;
+}
+
static void mdbox_map_cleanup(struct mdbox_map *map)
{
struct stat st;
diff -r b44b8ba23c5c -r 012a1773ebfd src/lib-storage/index/dbox-multi/mdbox-map.h
--- a/src/lib-storage/index/dbox-multi/mdbox-map.h Fri Sep 17 20:20:53 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.h Mon Sep 20 15:30:07 2010 +0100
@@ -31,8 +31,7 @@
ARRAY_DEFINE_TYPE(mdbox_map_file_msg, struct mdbox_map_file_msg);
struct mdbox_map *
-mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list,
- const char *path);
+mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list);
void mdbox_map_deinit(struct mdbox_map **map);
/* Open the map. Returns 1 if ok, 0 if map doesn't exist, -1 if error. */
diff -r b44b8ba23c5c -r 012a1773ebfd src/lib-storage/index/dbox-multi/mdbox-storage.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Fri Sep 17 20:20:53 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Mon Sep 20 15:30:07 2010 +0100
@@ -59,7 +59,8 @@
"/"MDBOX_GLOBAL_DIR_NAME, NULL);
i_array_init(&storage->open_files, 64);
- storage->map = mdbox_map_init(storage, ns->list, storage->storage_dir);
+ dir = mailbox_list_get_path(ns->list, NULL, MAILBOX_LIST_PATH_TYPE_DIR);
+ storage->map = mdbox_map_init(storage, ns->list);
return 0;
}
More information about the dovecot-cvs
mailing list