From 7d2097df9066484be09008b6736a133c4ea62d9d Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 14 Nov 2023 16:35:37 -0300 Subject: [PATCH] in_calyptia_fleet: remove configuration file directories for fleets without files. Signed-off-by: Phillip Whelan --- plugins/in_calyptia_fleet/in_calyptia_fleet.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/in_calyptia_fleet/in_calyptia_fleet.c b/plugins/in_calyptia_fleet/in_calyptia_fleet.c index 37608ba3d19..fb321a972bf 100644 --- a/plugins/in_calyptia_fleet/in_calyptia_fleet.c +++ b/plugins/in_calyptia_fleet/in_calyptia_fleet.c @@ -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; }