From 804475dc893b1e905572290042d30213770e06c3 Mon Sep 17 00:00:00 2001 From: kilo Date: Sun, 29 Oct 2017 04:38:33 +0100 Subject: [PATCH] Update torrent.go --- models/torrent.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/models/torrent.go b/models/torrent.go index e5237bdf..e68ed7d0 100644 --- a/models/torrent.go +++ b/models/torrent.go @@ -216,6 +216,14 @@ func (t *Torrent) ParseTrackers(trackers []string) { } } } + tempTrackers := []string{} + for _, line := range trackers { + if !contains(tempTrackers, line) { + tempTrackers = append(tempTrackers, line) + } + } + trackers = tempTrackers + v["tr"] = trackers t.Trackers = v.Encode() } @@ -517,3 +525,12 @@ func (t *Torrent) DeleteTags() { log.CheckErrorWithMessage(err, "LOAD_TAGS_ERROR: Couldn't delete tags!") } } + +func contains(s []string, e string) bool { + for _, a := range s { + if a == e { + return true + } + } + return false +}