diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-31 17:48:07 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-31 17:48:07 -0300 |
commit | 2cce8f101f772105244405667b9ba15ac2933146 (patch) | |
tree | 92317af67341847663c1c15315a6b66c989cda6c /git.c | |
parent | ae71a09d376d4b435e2290cda48dffa96d54b16b (diff) |
git: Make use of both `is_dir()`, and `mkdirp()` in
`create_pull_request_dir()`
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -634,9 +634,17 @@ int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root) { } /* Is there no existing directory? */ - if (stat(pr_dir, &st) < 0) { - /* Create a directory with a name of the stringified ID. */ - mkdir(pr_dir, 0755); + switch (is_dir(pr_dir)) { + /* PR root exists, and is a directory. */ + case 1 : break; + /* PR root exists, but isn't a directory. */ + case 0 : + log(LOG_ERR, "PR root \"%s\" exists, but isn't a directory.", pr_dir); + free(pr_dir); + return -1; + break; + /* PR root doesn't exist. */ + default : mkdirp(pr_dir, 0755); break; } /* Did we fail to create the info file? */ |