From eefdf8449a2ea656f71ec0149c14c2a4716536e8 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Mon, 18 Mar 2019 14:57:10 +0300 Subject: [PATCH] * filters: refactor: remove unused if-branches filter.ID == 0: Useless, because filter ID is assigned either on application load or on filter add. len(filter.Rules) == 0: Useless, because rules are added either on application load or on filter add or on filter enable. --- filter.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/filter.go b/filter.go index 400073da..6dedadc1 100644 --- a/filter.go +++ b/filter.go @@ -147,16 +147,6 @@ func refreshFiltersIfNecessary(force bool) int { continue } - if filter.ID == 0 { // protect against users modifying the yaml and removing the ID - filter.ID = assignUniqueFilterID() - } - - if len(filter.Rules) == 0 { - // Try reloading filter from the disk before updating - // This is useful for the case when we simply enable a previously downloaded filter - _ = filter.load() - } - updated, err := filter.update(force) if err != nil { log.Printf("Failed to update filter %s: %s\n", filter.URL, err) @@ -218,9 +208,6 @@ func parseFilterContents(contents []byte) (int, string, []string) { // If "force" is true -- does not check the filter's LastUpdated field // Call "save" to persist the filter contents func (filter *filter) update(force bool) (bool, error) { - if filter.ID == 0 { // protect against users deleting the ID - filter.ID = assignUniqueFilterID() - } if !force && time.Since(filter.LastUpdated) <= updatePeriod { return false, nil }