From b6cde49f9d054bb71d0e39d10c7c205554ab4d14 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Tue, 29 Mar 2022 19:53:08 +0300 Subject: [PATCH] Categories: Clean up deleted category records --- hyphae/categories/categories.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hyphae/categories/categories.go b/hyphae/categories/categories.go index a9533c6..4e26fa5 100644 --- a/hyphae/categories/categories.go +++ b/hyphae/categories/categories.go @@ -73,10 +73,16 @@ func RemoveHyphaFromCategory(hyphaName, catName string) { mutex.Lock() if node, ok := hyphaToCategories[hyphaName]; ok { node.removeCategory(catName) + if len(node.categoryList) == 0 { + delete(hyphaToCategories, hyphaName) + } } if node, ok := categoryToHyphae[catName]; ok { node.removeHypha(hyphaName) + if len(node.hyphaList) == 0 { + delete(categoryToHyphae, catName) + } } mutex.Unlock() go saveToDisk()