Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6824:b8c66f025583 HEAD
If control directory doesn't exist when trying to create subscriptions file,
create the directory.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 17 Nov 2007 02:07:40 +0200 |
parents | ee1c4c3d5e5a |
children | 85385079b044 |
files | src/lib-storage/list/subscription-file.c |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/subscription-file.c Fri Nov 16 23:55:31 2007 +0200 +++ b/src/lib-storage/list/subscription-file.c Sat Nov 17 02:07:40 2007 +0200 @@ -4,6 +4,7 @@ #include "istream.h" #include "ostream.h" #include "nfs-workarounds.h" +#include "mkdir-parents.h" #include "file-dotlock.h" #include "mailbox-list-private.h" #include "subscription-file.h" @@ -77,7 +78,7 @@ { struct dotlock_settings dotlock_set; struct dotlock *dotlock; - const char *line; + const char *line, *p, *dir; struct istream *input; struct ostream *output; int fd_in, fd_out; @@ -96,6 +97,16 @@ dotlock_set.stale_timeout = SUBSCRIPTION_FILE_CHANGE_TIMEOUT; fd_out = file_dotlock_open(&dotlock_set, path, 0, &dotlock); + if (fd_out == -1 && errno == ENOENT) { + /* directory hasn't been created yet. */ + p = strrchr(path, '/'); + dir = p == NULL ? NULL : t_strdup_until(path, p); + if (dir != NULL && mkdir_parents(dir, 0700) < 0) { + subsfile_set_syscall_error(list, "mkdir()", dir); + return -1; + } + fd_out = file_dotlock_open(&dotlock_set, path, 0, &dotlock); + } if (fd_out == -1) { if (errno == EAGAIN) { mailbox_list_set_error(list, MAIL_ERROR_TEMP,