diff options
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index 97ffc637..9601e691 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs | |||
@@ -71,16 +71,19 @@ lookupHandle ih = do | |||
71 | -- Initialization | 71 | -- Initialization |
72 | -----------------------------------------------------------------------} | 72 | -----------------------------------------------------------------------} |
73 | 73 | ||
74 | newExchangeSession :: FilePath -> InfoDict -> BitTorrent Exchange.Session | ||
75 | newExchangeSession rootPath dict = do | ||
76 | c @ Client {..} <- getClient | ||
77 | liftIO $ Exchange.newSession clientLogger (externalAddr c) rootPath dict | ||
78 | |||
74 | -- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open | 79 | -- | Open a torrent in 'stop'ed state. Use 'nullTorrent' to open |
75 | -- handle from 'InfoDict'. This operation do not block. | 80 | -- handle from 'InfoDict'. This operation do not block. |
76 | openTorrent :: FilePath -> Torrent -> BitTorrent Handle | 81 | openTorrent :: FilePath -> Torrent -> BitTorrent Handle |
77 | openTorrent rootPath t @ Torrent {..} = do | 82 | openTorrent rootPath t @ Torrent {..} = do |
78 | let ih = idInfoHash tInfoDict | 83 | let ih = idInfoHash tInfoDict |
79 | allocHandle ih $ do | 84 | allocHandle ih $ do |
80 | c @ Client {..} <- getClient | ||
81 | tses <- liftIO $ Tracker.newSession ih (trackerList t) | 85 | tses <- liftIO $ Tracker.newSession ih (trackerList t) |
82 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) | 86 | eses <- newExchangeSession rootPath tInfoDict |
83 | rootPath tInfoDict | ||
84 | return $ Handle | 87 | return $ Handle |
85 | { handleTopic = ih | 88 | { handleTopic = ih |
86 | , handlePrivate = idPrivate tInfoDict | 89 | , handlePrivate = idPrivate tInfoDict |
@@ -92,10 +95,8 @@ openTorrent rootPath t @ Torrent {..} = do | |||
92 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle | 95 | openMagnet :: FilePath -> Magnet -> BitTorrent Handle |
93 | openMagnet rootPath uri @ Magnet {..} = do | 96 | openMagnet rootPath uri @ Magnet {..} = do |
94 | allocHandle exactTopic $ do | 97 | allocHandle exactTopic $ do |
95 | c @ Client {..} <- getClient | ||
96 | tses <- liftIO $ Tracker.newSession exactTopic def | 98 | tses <- liftIO $ Tracker.newSession exactTopic def |
97 | eses <- liftIO $ Exchange.newSession clientLogger (externalAddr c) | 99 | eses <- newExchangeSession rootPath (error "openMagnet" exactTopic) |
98 | rootPath (error "openMagnet" exactTopic) | ||
99 | return $ Handle | 100 | return $ Handle |
100 | { handleTopic = exactTopic | 101 | { handleTopic = exactTopic |
101 | , handlePrivate = False | 102 | , handlePrivate = False |