Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5436:bbb7b3d57593 HEAD
Disable index files if index directory can't be created.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 27 Mar 2007 22:59:28 +0300 |
parents | bd1be5cb3985 |
children | 2704fc574e70 |
files | src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/mbox/mbox-storage.c |
diffstat | 2 files changed, 20 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-storage.c Tue Mar 27 01:27:34 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Tue Mar 27 22:59:28 2007 +0300 @@ -32,7 +32,8 @@ extern struct mail_storage maildir_storage; extern struct mailbox maildir_mailbox; -static int verify_inbox(struct mail_storage *storage); +static int verify_inbox(struct mail_storage *storage, + enum mailbox_open_flags *flags); static const char *strip_tail_slash(const char *path) { @@ -141,6 +142,7 @@ struct index_storage *istorage; struct mailbox_list_settings list_set; struct mailbox_list *list; + enum mailbox_open_flags open_flags; const char *error; struct stat st; pool_t pool; @@ -193,7 +195,8 @@ istorage->user = p_strdup(pool, user); index_storage_init(istorage, list, flags, lock_method); - (void)verify_inbox(STORAGE(storage)); + open_flags = 0; + (void)verify_inbox(STORAGE(storage), &open_flags); return STORAGE(storage); } @@ -330,8 +333,10 @@ mailbox_list_get_hierarchy_sep(storage->list), name); if (mkdir_parents(dir, CREATE_MODE) < 0 && errno != EEXIST) { - mail_storage_set_critical(storage, - "mkdir(%s) failed: %m", dir); + if (!ENOSPACE(errno)) { + mail_storage_set_critical(storage, + "mkdir(%s) failed: %m", dir); + } return -1; } @@ -361,7 +366,8 @@ return 0; } -static int verify_inbox(struct mail_storage *storage) +static int verify_inbox(struct mail_storage *storage, + enum mailbox_open_flags *flags) { const char *path; @@ -371,7 +377,7 @@ return -1; if (create_index_dir(storage, "INBOX") < 0) - return -1; + *flags |= MAILBOX_OPEN_NO_INDEX_FILES; if (create_control_dir(storage, "INBOX") < 0) return -1; return 0; @@ -478,7 +484,7 @@ } if (strcmp(name, "INBOX") == 0) { - if (verify_inbox(_storage) < 0) + if (verify_inbox(_storage, &flags) < 0) return NULL; return maildir_open(storage, "INBOX", flags); } @@ -498,7 +504,7 @@ if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) == 0) { if (create_index_dir(_storage, name) < 0) - return NULL; + flags |= MAILBOX_OPEN_NO_INDEX_FILES; } return maildir_open(storage, name, flags);
--- a/src/lib-storage/index/mbox/mbox-storage.c Tue Mar 27 01:27:34 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Tue Mar 27 22:59:28 2007 +0300 @@ -468,8 +468,10 @@ return 0; if (mkdir_parents(index_dir, CREATE_MODE) < 0) { - mail_storage_set_critical(storage, - "mkdir_parents(%s) failed: %m", index_dir); + if (!ENOSPACE(errno)) { + mail_storage_set_critical(storage, + "mkdir_parents(%s) failed: %m", index_dir); + } return -1; } @@ -604,7 +606,7 @@ if (*index_dir != '\0') { /* make sure the index directories exist */ if (create_mbox_index_dirs(_storage, name) < 0) - return NULL; + index_dir = ""; } index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX); @@ -643,7 +645,7 @@ /* make sure the required directories are also there */ if (create_mbox_index_dirs(_storage, name) < 0) - return NULL; + index_dir = ""; } index = index_storage_alloc(index_dir, path, MBOX_INDEX_PREFIX);