From: Ramakrishnan Muthukrishnan Date: Tue, 25 Jul 2017 07:32:15 +0000 (+0530) Subject: Metainfo: rename mkInfo -> bvalToInfo X-Git-Url: https://git.rkrishnan.org/specifications/vdrive/flags/something?a=commitdiff_plain;h=649552ae69615fe9c5d88883768e13a32d4e1b9c;p=functorrent.git Metainfo: rename mkInfo -> bvalToInfo --- diff --git a/src/FuncTorrent/Metainfo.hs b/src/FuncTorrent/Metainfo.hs index e555074..4cc6ed1 100644 --- a/src/FuncTorrent/Metainfo.hs +++ b/src/FuncTorrent/Metainfo.hs @@ -50,24 +50,24 @@ data Metainfo = Metainfo { info :: !(Maybe Info) , infoHash :: !ByteString } deriving (Eq, Show) -mkInfo :: BVal -> Maybe Info -mkInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length" - (Bstr pieces') = m ! "pieces" - private' = Nothing - (Bstr name') = m ! "name" - (Bint length') = m ! "length" - md5sum' = Nothing - in Just Info { pieceLength = pieceLength' - , pieces = pieces' - , private = private' - , name = unpack name' - , lengthInBytes = length' - , md5sum = md5sum'} -mkInfo _ = Nothing +bvalToInfo :: BVal -> Maybe Info +bvalToInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length" + (Bstr pieces') = m ! "pieces" + private' = Nothing + (Bstr name') = m ! "name" + (Bint length') = m ! "length" + md5sum' = Nothing + in Just Info { pieceLength = pieceLength' + , pieces = pieces' + , private = private' + , name = unpack name' + , lengthInBytes = length' + , md5sum = md5sum'} +bvalToInfo _ = Nothing mkMetaInfo :: BVal -> Either String Metainfo mkMetaInfo (Bdict m) = - let info' = mkInfo $ m ! "info" + let info' = bvalToInfo $ m ! "info" announce' = lookup "announce" m announceList' = lookup "announce-list" m creationDate' = lookup "creation date" m