From 7fd672a7cebf40e97379596bdb7afacadbf0b2be Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Thu, 15 Jul 2021 17:48:34 +0800 Subject: [PATCH] tracker list removes dup entries --- engine/engineUtil.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/engine/engineUtil.go b/engine/engineUtil.go index 756dfcfb..d26f6e49 100644 --- a/engine/engineUtil.go +++ b/engine/engineUtil.go @@ -72,14 +72,22 @@ func (e *Engine) ParseTrackerList() error { if lst, err := fetchTxtList(line[7:]); err == nil { trackers = append(trackers, lst...) } else { - log.Println("[ParseTrackerList] ignored", err) + log.Println("[ParseTrackerList] ignored", err, line) } } else { trackers = append(trackers, line) } } - e.Trackers = trackers + // remove duplicated entries + dupMap := make(map[string]struct{}) + for _, t := range trackers { + dupMap[t] = struct{}{} + } + for t := range dupMap { + e.Trackers = append(e.Trackers, t) + } + log.Printf("[ParseTrackerList] got %d trackers", len(e.Trackers)) return nil }