Module: kamailio
Branch: master
Commit: 6918a96cc61fa0b15e09db01bb02e9b9f8c78abf
URL:
https://github.com/kamailio/kamailio/commit/6918a96cc61fa0b15e09db01bb02e9b…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2019-11-28T14:28:14+01:00
cfgt: don't try to create dir if it already exists
---
Modified: src/modules/cfgt/cfgt_int.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6918a96cc61fa0b15e09db01bb02e9b…
Patch:
https://github.com/kamailio/kamailio/commit/6918a96cc61fa0b15e09db01bb02e9b…
---
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c
index 97ebe0b11d..e9f18718dc 100644
--- a/src/modules/cfgt/cfgt_int.c
+++ b/src/modules/cfgt/cfgt_int.c
@@ -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;
}