dovecot: If control directory doesn't exist when trying to creat...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Nov 17 02:07:44 EET 2007
details: http://hg.dovecot.org/dovecot/rev/b8c66f025583
changeset: 6824:b8c66f025583
user: Timo Sirainen <tss at iki.fi>
date: Sat Nov 17 02:07:40 2007 +0200
description:
If control directory doesn't exist when trying to create subscriptions file,
create the directory.
diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
src/lib-storage/list/subscription-file.c | 13 ++++++++++++-
diffs (37 lines):
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 @@ int subsfile_set_subscribed(struct mailb
{
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 @@ int subsfile_set_subscribed(struct mailb
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,
More information about the dovecot-cvs
mailing list