From 12285aaf8c84832236de856a2398fe1014fc5724 Mon Sep 17 00:00:00 2001 From: Tyrolyean Date: Thu, 30 Apr 2020 23:06:43 +0200 Subject: [PATCH] Directory creation fix Signed-off-by: Tyrolyean --- src/attach.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/attach.c b/src/attach.c index 30bdb15..1e700d2 100644 --- a/src/attach.c +++ b/src/attach.c @@ -29,6 +29,7 @@ #include #include #include +#include /* Generates an email struct from the given eml text. If the content is * multipart, it will be slit up into several email_ts. This expansion is done @@ -345,14 +346,12 @@ int replace_files(struct email_t* mail, const char* dirname, bool* created){ min_filesize ){ return 0; } - if(!*created){ - *created = true; - if(mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) - < 0){ + if(mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0){ + if(errno != EEXIST){ + perror("Failed to create storage directory!"); return -1; - } }