From 455a3e0f791287b91889d09a548dba875af8659c Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 24 Jan 2021 12:06:37 +0500 Subject: [PATCH] Fix hyphae count corruption on reindexation --- hyphae/count.go | 7 +++++++ main.go | 1 + 2 files changed, 8 insertions(+) diff --git a/hyphae/count.go b/hyphae/count.go index 2c1d5f1..d090606 100644 --- a/hyphae/count.go +++ b/hyphae/count.go @@ -10,6 +10,13 @@ var count = struct { sync.Mutex }{} +// Set the value of hyphae count to zero. +func ResetCount() { + count.Lock() + count.value = 0 + count.Unlock() +} + // Increment the value of hyphae count. func IncrementCount() { count.Lock() diff --git a/main.go b/main.go index 9daa2cd..cf79b9f 100644 --- a/main.go +++ b/main.go @@ -70,6 +70,7 @@ func handlerReindex(w http.ResponseWriter, rq *http.Request) { log.Println("Rejected", rq.URL) return } + hyphae.ResetCount() HyphaStorage = make(map[string]*HyphaData) log.Println("Wiki storage directory is", WikiDir) log.Println("Start indexing hyphae...")