Directory creation fix

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2020-04-30 23:06:43 +02:00
parent fa6027c437
commit 12285aaf8c
No known key found for this signature in database
GPG Key ID: 81EC9BAC5E9667C6
1 changed files with 4 additions and 5 deletions

View File

@ -29,6 +29,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
/* Generates an email struct from the given eml text. If the content is /* 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 * 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 ){ min_filesize ){
return 0; return 0;
} }
if(!*created){ if(mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0){
*created = true;
if(mkdir(directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
< 0){
if(errno != EEXIST){
perror("Failed to create storage directory!"); perror("Failed to create storage directory!");
return -1; return -1;
} }
} }