-bvalToInfo (Bdict m) = let (Bint pieceLength') = m ! "piece length"
- (Bstr pieces') = m ! "pieces"
- private' = Nothing
- (Bstr name') = m ! "name"
- -- 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
- partialInfo = Info { pieceLength = pieceLength'
- , pieces = pieces'
- , private = private'
- , name = unpack name'
- , filemeta = []
- }
- in
- case filesIfMulti of
- Nothing -> let (Bint length') = m ! "length"
- filemeta' = FileMeta { lengthInBytes = length'
- , md5sum = Nothing
- , path = unpack name' }
- in Just (partialInfo { filemeta = [filemeta'] })
- Just (Blist files) -> mapM toFileMeta files >>=
- \filemeta' ->
- Just partialInfo { filemeta = filemeta' }
+bvalToInfo (Bdict minfo) = let (Bint pieceLength') = minfo ! "piece length"
+ (Bstr pieces') = minfo ! "pieces"
+ private' = Nothing
+ (Bstr name') = minfo ! "name"
+ -- is the key "files" present? If so, it is a multi-file torrent
+ -- if not, it is a single file torrent.
+ filesIfMulti = lookup "files" minfo
+ partialInfo = Info { pieceLength = pieceLength'
+ , pieces = pieces'
+ , private = private'
+ , name = unpack name'
+ , filemeta = []
+ }
+ in
+ case filesIfMulti of
+ Nothing -> let (Bint length') = minfo ! "length"
+ filemeta' = FileMeta { lengthInBytes = length'
+ , md5sum = Nothing
+ , path = unpack name' }
+ in Just (partialInfo { filemeta = [filemeta'] })
+ Just (Blist files) -> mapM toFileMeta files >>=
+ \filemeta' ->
+ Just partialInfo { filemeta = filemeta' }
+ Just _ -> Nothing