dovecot-2.1: lib-storage: Added MAILBOX_LIST_FLAG_OPTIONAL_BOXES...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Nov 4 20:26:06 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/64ca27392217
changeset: 13649:64ca27392217
user: Timo Sirainen <tss at iki.fi>
date: Fri Nov 04 20:36:06 2011 +0200
description:
lib-storage: Added MAILBOX_LIST_FLAG_OPTIONAL_BOXES flag.
diffstat:
src/lib-storage/list/mailbox-list-fs.c | 58 ++++++++++++++++------------
src/lib-storage/list/mailbox-list-maildir.c | 13 +++---
src/lib-storage/mailbox-list.h | 6 ++-
3 files changed, 45 insertions(+), 32 deletions(-)
diffs (126 lines):
diff -r 926a7ceeaa10 -r 64ca27392217 src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c Fri Nov 04 20:11:39 2011 +0200
+++ b/src/lib-storage/list/mailbox-list-fs.c Fri Nov 04 20:36:06 2011 +0200
@@ -316,46 +316,54 @@
return t_strdup_printf("%s/"MAILBOX_LIST_FS_TRASH_DIR_NAME, root_dir);
}
-static int fs_list_delete_mailbox(struct mailbox_list *list, const char *name)
+static int
+fs_list_delete_maildir(struct mailbox_list *list, const char *name)
{
const char *path, *trash_dir;
- int ret = 0;
-
- if ((list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
- if (mailbox_list_delete_mailbox_file(list, name) < 0)
- return -1;
- ret = 1;
- }
+ bool rmdir_path;
+ int ret;
if (*list->set.maildir_name != '\0' &&
- *list->set.mailbox_dir_name != '\0' && ret == 0) {
+ *list->set.mailbox_dir_name != '\0') {
trash_dir = mailbox_list_fs_get_trash_dir(list);
ret = mailbox_list_delete_maildir_via_trash(list, name,
trash_dir);
if (ret < 0)
return -1;
- /* try to delete the parent directory */
- path = mailbox_list_get_path(list, name,
- MAILBOX_LIST_PATH_TYPE_DIR);
- if (rmdir(path) < 0 && errno != ENOENT &&
- errno != ENOTEMPTY && errno != EEXIST) {
- mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
- path);
+ if (ret > 0) {
+ /* try to delete the parent directory */
+ path = mailbox_list_get_path(list, name,
+ MAILBOX_LIST_PATH_TYPE_DIR);
+ if (rmdir(path) < 0 && errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
+ mailbox_list_set_critical(list,
+ "rmdir(%s) failed: %m", path);
+ }
+ return 0;
}
}
- if (ret == 0) {
- bool rmdir_path = *list->set.maildir_name != '\0';
+ rmdir_path = *list->set.maildir_name != '\0';
+ path = mailbox_list_get_path(list, name,
+ MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ return mailbox_list_delete_mailbox_nonrecursive(list, name, path,
+ rmdir_path);
+}
- path = mailbox_list_get_path(list, name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
- if (mailbox_list_delete_mailbox_nonrecursive(list, name, path,
- rmdir_path) < 0)
- return -1;
+static int fs_list_delete_mailbox(struct mailbox_list *list, const char *name)
+{
+ int ret;
+
+ if ((list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
+ ret = mailbox_list_delete_mailbox_file(list, name);
+ } else {
+ ret = fs_list_delete_maildir(list, name);
}
- mailbox_list_delete_finish(list, name);
- return 0;
+
+ if (ret == 0 || (list->flags & MAILBOX_LIST_FLAG_OPTIONAL_BOXES) != 0)
+ mailbox_list_delete_finish(list, name);
+ return ret;
}
static int fs_list_rmdir(struct mailbox_list *list, const char *name,
diff -r 926a7ceeaa10 -r 64ca27392217 src/lib-storage/list/mailbox-list-maildir.c
--- a/src/lib-storage/list/mailbox-list-maildir.c Fri Nov 04 20:11:39 2011 +0200
+++ b/src/lib-storage/list/mailbox-list-maildir.c Fri Nov 04 20:36:06 2011 +0200
@@ -402,16 +402,17 @@
static int
maildir_list_delete_mailbox(struct mailbox_list *list, const char *name)
{
+ int ret;
+
if ((list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
- if (mailbox_list_delete_mailbox_file(list, name) < 0)
- return -1;
+ ret = mailbox_list_delete_mailbox_file(list, name);
} else {
- if (maildir_list_delete_maildir(list, name) < 0)
- return -1;
+ ret = maildir_list_delete_maildir(list, name);
}
- mailbox_list_delete_finish(list, name);
- return 0;
+ if (ret == 0 || (list->flags & MAILBOX_LIST_FLAG_OPTIONAL_BOXES) != 0)
+ mailbox_list_delete_finish(list, name);
+ return ret;
}
static int maildir_list_delete_dir(struct mailbox_list *list, const char *name)
diff -r 926a7ceeaa10 -r 64ca27392217 src/lib-storage/mailbox-list.h
--- a/src/lib-storage/mailbox-list.h Fri Nov 04 20:11:39 2011 +0200
+++ b/src/lib-storage/mailbox-list.h Fri Nov 04 20:36:06 2011 +0200
@@ -32,7 +32,11 @@
MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01,
/* Namespace already has a mailbox list, don't assign this
mailbox list to it. */
- MAILBOX_LIST_FLAG_SECONDARY = 0x02
+ MAILBOX_LIST_FLAG_SECONDARY = 0x02,
+ /* Don't assume that just because a mailbox directory doesn't exist
+ its index/control directories don't exist (e.g. this is index-only
+ mailbox list) */
+ MAILBOX_LIST_FLAG_OPTIONAL_BOXES = 0x04
};
enum mailbox_info_flags {
More information about the dovecot-cvs
mailing list