aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2025-12-08 00:31:59 +0100
committerarf20 <aruizfernandez05@gmail.com>2025-12-08 00:31:59 +0100
commitc2977c08c4778d0dff74ca92441bc33789687947 (patch)
treed40430de2b8fa9a92c230fe98ddafcd8bd6eee59 /main.c
parent0159795be5aa8423e8d223d057912e2d152efb4f (diff)
downloadarfnet2-search-c2977c08c4778d0dff74ca92441bc33789687947.tar.gz
arfnet2-search-c2977c08c4778d0dff74ca92441bc33789687947.zip
periodic reindexing
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 17 insertions, 14 deletions
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);
}