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; - } }