From 01d48a9dc7d32869cff59369e6b4968473a49456 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sat, 14 Dec 2013 21:53:19 +0400 Subject: Test InvalidIndex and InvalidSize exceptions --- src/System/Torrent/Storage.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/System/Torrent/Storage.hs') diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs index bf44d7bf..8ad4d3e5 100644 --- a/src/System/Torrent/Storage.hs +++ b/src/System/Torrent/Storage.hs @@ -45,7 +45,7 @@ import Data.Typeable import Data.Torrent.Bitfield import Data.Torrent.Layout import Data.Torrent.Piece -import System.Torrent.FileMap +import System.Torrent.FileMap as FM data StorageFailure @@ -82,7 +82,9 @@ withStorage :: Mode -> PieceSize -> FileLayout FileSize withStorage m s l = bracket (open m s l) close isValidIx :: PieceIx -> Storage -> Bool -isValidIx i s = 0 <= i && i < undefined s +isValidIx i Storage {..} = 0 <= i && i < pcount + where + pcount = FM.size fileMap `sizeInBase` pieceLen writePiece :: Piece BL.ByteString -> Storage -> IO () writePiece p @ Piece {..} s @ Storage {..} -- cgit v1.2.3