From 0a0d09bca9b312de72b4ca57904fae3a7f423e4b Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sat, 8 Feb 2014 04:02:17 +0400 Subject: Allow empty tracker list --- src/Network/BitTorrent/Tracker/List.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/Tracker/List.hs b/src/Network/BitTorrent/Tracker/List.hs index b6371f1d..f2a4b264 100644 --- a/src/Network/BitTorrent/Tracker/List.hs +++ b/src/Network/BitTorrent/Tracker/List.hs @@ -26,6 +26,7 @@ import Prelude hiding (mapM, foldr) import Control.Applicative import Control.Exception import Data.List as L (elem, any, filter, null) +import Data.Maybe import Data.Foldable import Data.Traversable import Network.URI @@ -95,9 +96,10 @@ fixList mxss mx = do -- | Extract set of trackers from torrent file. The 'tAnnounce' key is -- only ignored if the 'tAnnounceList' key is present. -trackerList :: Torrent -> Maybe (TrackerList URI) -trackerList Torrent {..} = TierList <$> (tAnnounceList `fixList` tAnnounce) - <|> Announce <$> tAnnounce +trackerList :: Torrent -> TrackerList URI +trackerList Torrent {..} = fromMaybe (TierList []) $ do + TierList <$> (tAnnounceList `fixList` tAnnounce) + <|> Announce <$> tAnnounce -- | Shuffle /order of trackers/ in each tier, preserving original -- /order of tiers/. This can help to balance the load between the -- cgit v1.2.3