Skip to content

Commit

Permalink
cfgt: don't try to create dir if it already exists
Browse files Browse the repository at this point in the history
(cherry picked from commit 6918a96)
  • Loading branch information
linuxmaniac committed Nov 28, 2019
1 parent 7e5b726 commit aa94a3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/modules/cfgt/cfgt_int.c
Expand Up @@ -320,13 +320,16 @@ void cfgt_save_node(cfgt_node_p node)
FILE *fp;
str dest = STR_NULL;
int dir = 0;
struct stat sb;
if(_cfgt_get_filename(node->msgid, node->uuid, &dest, &dir) < 0) {
LM_ERR("can't build filename\n");
return;
}
dest.s[dir] = '\0';
LM_DBG("dir [%s]\n", dest.s);
if(mkdir(dest.s, S_IRWXO | S_IXGRP | S_IRWXU) < 0) {
if (stat(dest.s, &sb) == 0 && S_ISDIR(sb.st_mode)) {
LM_DBG("dir [%s] already existing\n", dest.s);
} else if(mkdir(dest.s, S_IRWXO | S_IXGRP | S_IRWXU) < 0) {
LM_ERR("failed to make directory: %s\n", strerror(errno));
return;
}
Expand Down

0 comments on commit aa94a3a

Please sign in to comment.