From 1bf7946e58a75babd0ed0ce693a5558ae579aba7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 24 Sep 2020 22:47:56 +0200 Subject: [PATCH] Delete filterlist entry if update has no sources --- intel/filterlists/database.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/intel/filterlists/database.go b/intel/filterlists/database.go index bff14c5e..6c1bb695 100644 --- a/intel/filterlists/database.go +++ b/intel/filterlists/database.go @@ -197,6 +197,7 @@ func normalizeEntry(entry *listEntry) { func processEntry(ctx context.Context, filter *scopedBloom, entry *listEntry, records chan<- record.Record) error { normalizeEntry(entry) + // Only add the entry to the bloom filter if it has any sources. if len(entry.Sources) > 0 { filter.add(entry.Type, entry.Entity) } @@ -208,6 +209,12 @@ func processEntry(ctx context.Context, filter *scopedBloom, entry *listEntry, re UpdatedAt: time.Now().Unix(), } + // If the entry is a "delete" update, actually delete it to save space. + if len(entry.Sources) == 0 { + r.CreateMeta() + r.Meta().Delete() + } + key := makeListCacheKey(strings.ToLower(r.Type), r.Value) r.SetKey(key)