Module: kamailio Branch: 5.2 Commit: fa7778816de04aea0b23f4cce06fd8af6da598fb URL: https://github.com/kamailio/kamailio/commit/fa7778816de04aea0b23f4cce06fd8af...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2019-11-28T14:55:42+01:00
cfgt: don't try to create dir if it already exists
(cherry picked from commit 6918a96cc61fa0b15e09db01bb02e9b9f8c78abf)
---
Modified: src/modules/cfgt/cfgt_int.c
---
Diff: https://github.com/kamailio/kamailio/commit/fa7778816de04aea0b23f4cce06fd8af... Patch: https://github.com/kamailio/kamailio/commit/fa7778816de04aea0b23f4cce06fd8af...
---
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c index 1c5b938e9c..0e3bfecb5d 100644 --- a/src/modules/cfgt/cfgt_int.c +++ b/src/modules/cfgt/cfgt_int.c @@ -322,13 +322,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; }