Skip to content

Commit

Permalink
fix rmtree
Browse files Browse the repository at this point in the history
  • Loading branch information
palage4a committed Aug 17, 2023
1 parent 93a22a3 commit 390f645
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cartridge/clusterwide-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,25 @@ static int rmtree(const char *path) {
if(strcmp(ep->d_name, ".") == 0 ||
strcmp(ep->d_name, "..") == 0)
continue;
char tmp_path[512];
sprintf(tmp_path, "%s/%s", path, ep->d_name);
if(ep->d_type == DT_DIR) {
char tmp_path[512];
sprintf(tmp_path, "%s/%s", path, ep->d_name);
if(rmtree((const char*)tmp_path) == -1) {
say_error("%s: %s", path, strerror(errno));
int rc = rmtree((const char*)tmp_path);
if(rc == -1) {
say_error("%s: %s", tmp_path, strerror(errno));
return -1;
}
} else {
if(remove(path) == -1) {
say_error("%s:%s", path, strerror(errno));
if(unlink(tmp_path) == -1) {
say_error("%s: %s", path, strerror(errno));
return -1;
}
}
}
if(rmdir(path) == -1) {
say_error("%s: %s", path, strerror(errno));
return -1;
}
closedir(dp);
}
return 0;
Expand Down

0 comments on commit 390f645

Please sign in to comment.