From: Christopher John CZETTEL Date: Mon, 19 Jun 2017 01:54:33 +0000 (+0200) Subject: fix: maildir creation X-Git-Tag: neomutt-20170707~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eebf72008a790dc3214d89beeea4daf815c2b5bc;p=neomutt fix: maildir creation - added missing recursive directory creation after user prompt - checked for trailing '/' when saving mbox --- diff --git a/commands.c b/commands.c index 9002f0d15..bd740b736 100644 --- a/commands.c +++ b/commands.c @@ -801,6 +801,15 @@ int mutt_save_message(struct Header *h, int delete, int decode, int decrypt) else strfcpy(LastSaveFolder, buf, sizeof(LastSaveFolder)); + /* check if path is a filename by comparing last character + * (mboxes need filenames, not directories) + */ + if (DefaultMagic == MUTT_MBOX && buf[strlen(buf) - 1] == '/') + { + mutt_error(_("'%s' is a directory, need a filename for mbox."), buf); + return -1; + } + mutt_expand_path(buf, sizeof(buf)); /* check to make sure that this file is really the one the user wants */ diff --git a/muttlib.c b/muttlib.c index 3942e72ee..40608929f 100644 --- a/muttlib.c +++ b/muttlib.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1865,6 +1866,7 @@ int mutt_save_confirm(const char *s, struct stat *st) st->st_mtime = 0; st->st_atime = 0; + /* pathname does not exist */ if (errno == ENOENT) { if (option(OPTCONFIRMCREATE)) @@ -1875,6 +1877,20 @@ int mutt_save_confirm(const char *s, struct stat *st) else if (rc == MUTT_ABORT) ret = -1; } + + /* user confirmed with MUTT_YES or set OPTCONFIRMCREATE */ + if (ret == 0) + { + strncpy(tmp, s, sizeof(tmp) - 1); + + /* create dir recursively */ + if (mutt_mkdir(dirname(tmp), S_IRWXU) == -1) + { + /* report failure & abort */ + mutt_perror(s); + return 1; + } + } } else {