# HG changeset patch # User Timo Sirainen # Date 1195258060 -7200 # Node ID b8c66f0255835146a3fa2a959eec3ff65d05fe84 # Parent ee1c4c3d5e5a46f3eb19cffa0cc3595c545e32db If control directory doesn't exist when trying to create subscriptions file, create the directory. diff -r ee1c4c3d5e5a -r b8c66f025583 src/lib-storage/list/subscription-file.c --- 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,