diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-07-16 07:48:12 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-07-16 07:48:12 +0400 |
commit | 8c6e5818ee6b901efd975392c54aff5cf2721ae4 (patch) | |
tree | 85508d873378f3c0bfac21d09107ba6ff6155346 /src/Network/BitTorrent.hs | |
parent | 7ad3fd1f6fe3c6719b69f3638542f24b32a3b09c (diff) |
~ A few fixes in session.
Diffstat (limited to 'src/Network/BitTorrent.hs')
-rw-r--r-- | src/Network/BitTorrent.hs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/Network/BitTorrent.hs b/src/Network/BitTorrent.hs index 26824724..ad96a1b8 100644 --- a/src/Network/BitTorrent.hs +++ b/src/Network/BitTorrent.hs | |||
@@ -9,11 +9,11 @@ | |||
9 | module Network.BitTorrent | 9 | module Network.BitTorrent |
10 | ( module Data.Torrent | 10 | ( module Data.Torrent |
11 | 11 | ||
12 | , TorrentLoc(..), Progress(..) | 12 | , TorrentLoc(..), TorrentMap, Progress(..) |
13 | , ThreadCount, SessionCount | 13 | , ThreadCount, SessionCount |
14 | 14 | ||
15 | , ClientSession( clientPeerId, allowedExtensions ) | 15 | , ClientSession( clientPeerId, allowedExtensions ) |
16 | , withDefaultClient, defaultThreadCount | 16 | , withDefaultClient, defaultThreadCount, defaultPorts |
17 | , addTorrent | 17 | , addTorrent |
18 | , removeTorrent | 18 | , removeTorrent |
19 | 19 | ||
@@ -21,6 +21,8 @@ module Network.BitTorrent | |||
21 | , getPeerCount | 21 | , getPeerCount |
22 | , getSwarmCount | 22 | , getSwarmCount |
23 | , getSessionCount | 23 | , getSessionCount |
24 | , getSwarm | ||
25 | , getStorage | ||
24 | 26 | ||
25 | -- * Extensions | 27 | -- * Extensions |
26 | , Extension | 28 | , Extension |
@@ -33,6 +35,7 @@ import Data.Torrent | |||
33 | import Network.BitTorrent.Sessions.Types | 35 | import Network.BitTorrent.Sessions.Types |
34 | import Network.BitTorrent.Sessions | 36 | import Network.BitTorrent.Sessions |
35 | import Network.BitTorrent.Extension | 37 | import Network.BitTorrent.Extension |
38 | import Network.BitTorrent.Tracker | ||
36 | 39 | ||
37 | -- TODO remove fork from Network.BitTorrent.Exchange | 40 | -- TODO remove fork from Network.BitTorrent.Exchange |
38 | -- TODO make all forks in Internal. | 41 | -- TODO make all forks in Internal. |
@@ -46,22 +49,11 @@ withDefaultClient listPort dhtPort action = do | |||
46 | Torrent management | 49 | Torrent management |
47 | -----------------------------------------------------------------------} | 50 | -----------------------------------------------------------------------} |
48 | 51 | ||
49 | -- | Used to check torrent location before register torrent. | ||
50 | validateLocation :: TorrentLoc -> IO Torrent | ||
51 | validateLocation TorrentLoc {..} = do | ||
52 | t <- fromFile metafilePath | ||
53 | -- exists <- doesDirectoryExist dataDirPath | ||
54 | -- unless exists $ do | ||
55 | -- throw undefined | ||
56 | return t | ||
57 | |||
58 | |||
59 | -- | Register torrent and start downloading. | 52 | -- | Register torrent and start downloading. |
60 | addTorrent :: ClientSession -> TorrentLoc -> IO () | 53 | addTorrent :: ClientSession -> TorrentLoc -> IO () |
61 | addTorrent clientSession loc @ TorrentLoc {..} = do | 54 | addTorrent cs loc @ TorrentLoc {..} = do |
62 | torrent <- validateLocation loc | 55 | registerTorrent cs loc |
63 | -- registerTorrent loc tInfoHash | 56 | openSwarmSession cs loc |
64 | -- when (bf is not full) | ||
65 | return () | 57 | return () |
66 | 58 | ||
67 | -- | Unregister torrent and stop all running sessions. | 59 | -- | Unregister torrent and stop all running sessions. |
@@ -73,4 +65,4 @@ removeTorrent ses loc = undefined -- atomically $ unregisterTorrent ses loc | |||
73 | -- content files. | 65 | -- content files. |
74 | deleteTorrent :: ClientSession -> TorrentLoc -> IO () | 66 | deleteTorrent :: ClientSession -> TorrentLoc -> IO () |
75 | deleteTorrent ClientSession {..} TorrentLoc {..} = undefined | 67 | deleteTorrent ClientSession {..} TorrentLoc {..} = undefined |
76 | -} \ No newline at end of file | 68 | -} |