From 8e86703f0ed16c437a13d14ad97c3b4cb5da31b6 Mon Sep 17 00:00:00 2001 From: Tony Blyler Date: Sat, 14 May 2016 16:24:59 -0400 Subject: [PATCH] Add some extra logging when adding a torrent file. --- queue/queue.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/queue/queue.go b/queue/queue.go index eed21eb..70bdc53 100644 --- a/queue/queue.go +++ b/queue/queue.go @@ -198,6 +198,11 @@ func (q *Queue) addTorrentFilePath(path string) error { q.downloadQueue[torrentHash] = path + if _, exists := q.torrentList[torrentHash]; exists { + // the torrent is already on the server + return nil + } + return q.rtClient.AddTorrent(torrentData) } @@ -210,7 +215,9 @@ func (q *Queue) getFinishedTorrents() []rtorrent.Torrent { q.lock.RUnlock() err := q.addTorrentFilePath(torrentPath) q.lock.RLock() - if err != nil { + if err == nil { + q.logger.Printf("Added torrent '%s' to rTorrent", torrentPath) + } else { q.logger.Printf("Unable to add torrent '%s' error '%s'", torrentPath, err) } @@ -358,7 +365,9 @@ func (q *Queue) Run(stop <-chan bool) { q.logger.Printf("Adding %s to download queue", fullPath) err = q.addTorrentFilePath(fullPath) - if err != nil { + if err == nil { + q.logger.Printf("Added torrent '%s' to rTorrent", fullPath) + } else { q.logger.Printf("Failed to add torrent at '%s' error '%s'", fullPath, err) } } @@ -401,7 +410,9 @@ func (q *Queue) Run(stop <-chan bool) { q.logger.Printf("Adding %s to download queue", event.Name) err = q.addTorrentFilePath(event.Name) - if err != nil { + if err == nil { + q.logger.Printf("Added torrent '%s' to rTorrent", event.Name) + } else { q.logger.Printf("Failed to add '%s' error '%s'", event.Name, err) } }