Bencode, Metainfo: remove warnings and general cleanup
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Wed, 26 Jul 2017 05:49:58 +0000 (11:19 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Wed, 26 Jul 2017 05:49:58 +0000 (11:19 +0530)
src/FuncTorrent/Bencode.hs
src/FuncTorrent/Metainfo.hs

index fd521dcb58a774bbcc384db8da9b7c1b431e4589..28f0460a828af94d7d47ca978ed3bf4e290f6980 100644 (file)
@@ -20,9 +20,6 @@
 {-# LANGUAGE OverloadedStrings #-}
 module FuncTorrent.Bencode
     (BVal(..)
-    , bValToBList
-    , bValToBytestr
-    , bValToInfoDict
     , bValToInteger
     , bstrToString
     , decode
@@ -33,7 +30,7 @@ import Prelude hiding (length, concat)
 
 import Data.ByteString (ByteString, length, concat)
 import Data.ByteString.Char8 (unpack, pack)
-import Data.Char (isLetter, isNumber, isPrint, isAscii)
+import Data.Char (isLetter, isAscii)
 import Data.Map.Strict (Map, fromList, toList)
 import Text.ParserCombinators.Parsec
 import qualified Text.Parsec.ByteString as ParsecBS
@@ -75,14 +72,6 @@ bValToBytestr :: BVal  -> Maybe ByteString
 bValToBytestr (Bstr bs) = Just bs
 bValToBytestr _         = Nothing
 
-bValToBList :: BVal    -> Maybe [BVal]
-bValToBList (Blist lst) = Just lst
-bValToBList _           = Nothing
-
-bValToInfoDict :: BVal     -> Maybe (Map String BVal)
-bValToInfoDict (Bdict dict) = Just dict
-bValToInfoDict _            = Nothing
-
 bstrToString :: BVal -> Maybe String
 bstrToString bval     = unpack <$> bValToBytestr bval
 
index 801b53d4a88d039f79cb4102767bea9b909fa247..3f860ec1d062d3fe46b24e4e112e8eea393db959 100644 (file)
@@ -62,12 +62,11 @@ bvalToInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length"
                            -- is the key "files" present? If so, it is a multi-file torrent
                            -- if not, it is a single file torrent.
                            filesIfMulti = lookup "files" m
-                           (Bint length') = m ! "length"
-                           md5sum' = Nothing
                            partialInfo = Info { pieceLength = pieceLength'
                                                , pieces = pieces'
                                                , private = private'
                                                , name = unpack name'
+                                               , filemeta = []
                                                }
                        in
                          case filesIfMulti of