summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-08 04:02:17 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-08 04:02:17 +0400
commit0a0d09bca9b312de72b4ca57904fae3a7f423e4b (patch)
tree2dfe5b323397da9d9e44357ed616ed539dd3c72d /src
parent87da9eff1ce81b93de5bbd5af13643c4abbe6d05 (diff)
Allow empty tracker list
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/Tracker/List.hs8
1 files changed, 5 insertions, 3 deletions
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)
26import Control.Applicative 26import Control.Applicative
27import Control.Exception 27import Control.Exception
28import Data.List as L (elem, any, filter, null) 28import Data.List as L (elem, any, filter, null)
29import Data.Maybe
29import Data.Foldable 30import Data.Foldable
30import Data.Traversable 31import Data.Traversable
31import Network.URI 32import Network.URI
@@ -95,9 +96,10 @@ fixList mxss mx = do
95 96
96-- | Extract set of trackers from torrent file. The 'tAnnounce' key is 97-- | Extract set of trackers from torrent file. The 'tAnnounce' key is
97-- only ignored if the 'tAnnounceList' key is present. 98-- only ignored if the 'tAnnounceList' key is present.
98trackerList :: Torrent -> Maybe (TrackerList URI) 99trackerList :: Torrent -> TrackerList URI
99trackerList Torrent {..} = TierList <$> (tAnnounceList `fixList` tAnnounce) 100trackerList Torrent {..} = fromMaybe (TierList []) $ do
100 <|> Announce <$> tAnnounce 101 TierList <$> (tAnnounceList `fixList` tAnnounce)
102 <|> Announce <$> tAnnounce
101 103
102-- | Shuffle /order of trackers/ in each tier, preserving original 104-- | Shuffle /order of trackers/ in each tier, preserving original
103-- /order of tiers/. This can help to balance the load between the 105-- /order of tiers/. This can help to balance the load between the