torrent 10000.1.1 → 10000.1.3
raw patch · 3 files changed
+33/−20 lines, 3 filesdep ~bencode
Dependency ranges changed: bencode
Files
- CHANGELOG +12/−0
- src/Data/Torrent.hs +17/−17
- torrent.cabal +4/−3
CHANGELOG view
@@ -1,3 +1,15 @@+haskell-torrent (10000.1.3) unstable; urgency=medium++ * Update to cabal-version: >= 1.10 so Hackage will accept uploads again.++ -- Joey Hess <id@joeyh.name> Tue, 21 Mar 2023 20:44:19 -0400++haskell-torrent (10000.1.2) unstable; urgency=medium++ * Updated to build without deprecation warnings from bencode-0.6.1.0++ -- Joey Hess <id@joeyh.name> Tue, 21 Mar 2023 20:43:50 -0400+ haskell-torrent (10000.1.1) unstable; urgency=medium * Fix build with pre-AMP base.
src/Data/Torrent.hs view
@@ -15,10 +15,11 @@ ) where import Data.BEncode-import Data.BEncode.Parser+import Data.BEncode.Reader import Data.Binary import Data.Generics import Data.Maybe+import Control.Applicative import qualified Data.ByteString.Lazy as BS import Data.ByteString.Lazy (ByteString)@@ -73,30 +74,29 @@ readTorrent :: ByteString -> Either String Torrent readTorrent inp = case bRead inp of Nothing -> Left "Not BEncoded"- Just be -> runParser parseTorrent be+ Just be -> runBReader parseTorrent be -parseTorrent :: BParser Torrent+parseTorrent :: BReader Torrent parseTorrent = do- announce <- optional $ bbytestring $ dict "announce"- creator <- optional $ bbytestring $ dict "created by"- info <- dict "info"- setInput info- name <- bbytestring $ dict "name"- pLen <- bint $ dict "piece length"- pieces <- bbytestring $ dict "pieces"- torrentInfo <- parseTorrentInfo name pLen pieces- return $ Torrent announce [] BS.empty creator torrentInfo+ announce <- optional $ dict "announce" bbytestring+ creator <- optional $ dict "created by" bbytestring+ dict "info" $ do+ name <- dict "name" bbytestring+ pLen <- dict "piece length" bint+ pieces <- dict "pieces" bbytestring+ torrentInfo <- parseTorrentInfo name pLen pieces+ return $ Torrent announce [] BS.empty creator torrentInfo -parseTorrentInfo :: ByteString -> Integer -> ByteString -> BParser TorrentInfo+parseTorrentInfo :: ByteString -> Integer -> ByteString -> BReader TorrentInfo parseTorrentInfo name pLen pieces = single <|> multi where single = do- len <- bint $ dict "length"+ len <- dict "length" bint return $ SingleFile len name pLen pieces multi = do- files <- list "files" $ do- len <- bint $ dict "length"- filePaths <- list "path" $ bbytestring token+ files <- dict "files" $ list $ do+ len <- dict "length" bint+ filePaths <- dict "path" (list bbytestring) return $ TorrentFile len filePaths return $ MultiFile files name pLen pieces
torrent.cabal view
@@ -1,6 +1,6 @@ Name: torrent-Version: 10000.1.1-Cabal-Version: >= 1.6+Version: 10000.1.3+Cabal-Version: >= 1.10 Maintainer: Joey Hess <id@joeyh.name> Author: Lemmih <lemmih@gmail.com> Copyright: 2005-2007, Lemmih@@ -14,10 +14,11 @@ Library GHC-Options: -Wall -fno-warn-tabs Hs-Source-Dirs: src+ Default-Language: Haskell2010 Exposed-Modules: Data.Torrent Data.Torrent.Scrape- Build-Depends: base >= 4.5, base < 5, binary, bencode >=0.2,+ Build-Depends: base >= 4.5, base < 5, binary, bencode >= 0.6.1.0, filepath, containers, bytestring, syb source-repository head