From c2977c08c4778d0dff74ca92441bc33789687947 Mon Sep 17 00:00:00 2001 From: arf20 Date: Mon, 8 Dec 2025 00:31:59 +0100 Subject: periodic reindexing --- main.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 4716c97..d4e0a14 100644 --- a/main.c +++ b/main.c @@ -347,27 +347,30 @@ int main() { return 1; } - /* begin indexing */ if (index_init() < 0) return 1; - time_t time_now = time(NULL); - struct tm *tm_now = gmtime(&time_now); - static char timestr[256]; - strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); + /* index loop */ + do { + time_t time_now = time(NULL); + struct tm *tm_now = gmtime(&time_now); + static char timestr[256]; + strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); - printf("[%s] [index] indexeding started...\n", timestr); + printf("[%s] [index] indexeding started...\n", timestr); - g_index = index_new(INIT_MAP_CAPACITY, root, 1); + if (g_index) + index_destroy(g_index); - time_now = time(NULL); - tm_now = gmtime(&time_now); - strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); + g_index = index_new(INIT_MAP_CAPACITY, root, magic_enable); - printf("[%s] [index] indexed finished\n", timestr); + time_now = time(NULL); + tm_now = gmtime(&time_now); + strftime(timestr, 256, "%Y-%m-%d %H:%M:%S", tm_now); - while (1) { - sleep(1000); - } + printf("[%s] [index] indexed finished\n", timestr); + + sleep(period); + } while (1); } -- cgit v1.2.3