diff options
Diffstat (limited to 'src/System')
-rw-r--r-- | src/System/Torrent/Storage.hs | 6 |
1 files changed, 4 insertions, 2 deletions
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 | |||
45 | import Data.Torrent.Bitfield | 45 | import Data.Torrent.Bitfield |
46 | import Data.Torrent.Layout | 46 | import Data.Torrent.Layout |
47 | import Data.Torrent.Piece | 47 | import Data.Torrent.Piece |
48 | import System.Torrent.FileMap | 48 | import System.Torrent.FileMap as FM |
49 | 49 | ||
50 | 50 | ||
51 | data StorageFailure | 51 | data StorageFailure |
@@ -82,7 +82,9 @@ withStorage :: Mode -> PieceSize -> FileLayout FileSize | |||
82 | withStorage m s l = bracket (open m s l) close | 82 | withStorage m s l = bracket (open m s l) close |
83 | 83 | ||
84 | isValidIx :: PieceIx -> Storage -> Bool | 84 | isValidIx :: PieceIx -> Storage -> Bool |
85 | isValidIx i s = 0 <= i && i < undefined s | 85 | isValidIx i Storage {..} = 0 <= i && i < pcount |
86 | where | ||
87 | pcount = FM.size fileMap `sizeInBase` pieceLen | ||
86 | 88 | ||
87 | writePiece :: Piece BL.ByteString -> Storage -> IO () | 89 | writePiece :: Piece BL.ByteString -> Storage -> IO () |
88 | writePiece p @ Piece {..} s @ Storage {..} | 90 | writePiece p @ Piece {..} s @ Storage {..} |