Skip to content

Commit

Permalink
in_calyptia_fleet: remove configuration file directories for fleets w…
Browse files Browse the repository at this point in the history
…ithout files.

Signed-off-by: Phillip Whelan <[email protected]>
  • Loading branch information
pwhelan committed Nov 14, 2023
1 parent 471d7e7 commit 7d2097d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,24 +1331,22 @@ static int calyptia_config_delete_old_dir(const char *cfgpath)
}

files = read_glob(cfg_glob);
if (files == NULL) {
flb_sds_destroy(cfg_glob);
return FLB_FALSE;
}

for (idx = 0; idx < ((ssize_t)files->entry_count); idx++) {
unlink(files->entries[idx]->data.as_string);
if (files != NULL) {
for (idx = 0; idx < ((ssize_t)files->entry_count); idx++) {
unlink(files->entries[idx]->data.as_string);
}
cfl_array_destroy(files);
}

/* attempt to delete the main directory */
ext = strrchr(cfg_glob, '/');
ext = strrchr(cfg_glob, PATH_SEPARATOR[0]);
if (ext) {
*ext = '\0';
rmdir(cfg_glob);
}

flb_sds_destroy(cfg_glob);
cfl_array_destroy(files);

return FLB_TRUE;
}
Expand Down

0 comments on commit 7d2097d

Please sign in to comment.