diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-06 22:28:21 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-01-06 22:28:21 +0400 |
commit | 6f3d7093d6e1c2e3c5138da58b850778759435f8 (patch) | |
tree | 7e636aa82fba6924a052e326dca8dd88d2209b81 /src/System/Torrent | |
parent | e36b714d8eb0444459ea7051feb7b1c9af4154df (diff) |
Check piece size in the open function
Diffstat (limited to 'src/System/Torrent')
-rw-r--r-- | src/System/Torrent/Storage.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/System/Torrent/Storage.hs b/src/System/Torrent/Storage.hs index 6dda07e1..5315d9dc 100644 --- a/src/System/Torrent/Storage.hs +++ b/src/System/Torrent/Storage.hs | |||
@@ -90,7 +90,9 @@ data Storage = Storage | |||
90 | -- * when seeding, validation 'ReadOnly' mode. | 90 | -- * when seeding, validation 'ReadOnly' mode. |
91 | -- | 91 | -- |
92 | open :: Mode -> PieceSize -> FileLayout FileSize -> IO Storage | 92 | open :: Mode -> PieceSize -> FileLayout FileSize -> IO Storage |
93 | open mode s l = Storage mode s <$> mmapFiles mode l | 93 | open mode s l |
94 | | s <= 0 = throwIO (InvalidSize s) | ||
95 | | otherwise = Storage mode s <$> mmapFiles mode l | ||
94 | 96 | ||
95 | -- | Unmaps all files forcefully. It is recommended but not required. | 97 | -- | Unmaps all files forcefully. It is recommended but not required. |
96 | close :: Storage -> IO () | 98 | close :: Storage -> IO () |