From 9a67b35ebe9d92429dd812bd5d8e986f854f04f0 Mon Sep 17 00:00:00 2001 From: nova Date: Sat, 15 Nov 2025 22:21:30 +0100 Subject: [PATCH] handling of '/' in thread_lft --- threading.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/threading.c b/threading.c index 8a00b16..6a28073 100644 --- a/threading.c +++ b/threading.c @@ -122,17 +122,24 @@ void *thread_lft(){ char *path = malloc(strlen(global_path)+1); memcpy(path, global_path, strlen(global_path)+1); - path[strrchr(path, '/')-path] = '\0'; - path[0] = '/'; + if (strcmp(path, "/") != 0) { + path[strrchr(path, '/')-path+1] = '\0'; + path[strrchr(path, '/')-path] = '\0'; + path[0] = '/'; - if (local_status & STATUS_RELOAD_DIRECTORY) { - lft_file_count = get_dir_size(path); - free(lft_content); - lft_content = malloc(lft_file_count * sizeof(file)); - memset(lft_content, '\0', lft_file_count * sizeof(file)); - get_dir_content(path, &lft_file_count, lft_content); + if (local_status & STATUS_RELOAD_DIRECTORY) { + lft_file_count = get_dir_size(path); + free(lft_content); + lft_content = malloc(lft_file_count * sizeof(file)); + memset(lft_content, '\0', lft_file_count * sizeof(file)); + get_dir_content(path, &lft_file_count, lft_content); + } + + } else { + lft_file_count = 0; } + free(path); } pthread_mutex_unlock(&mutex_lft);