on master help sign in
wai-app-static: use cryptonite instead of cryptohash
commita2327adcd68ff58b32c5d0be4d3cebfc21765b6d authorGreg V <greg@unrelenting.technology> dateSat 12 Mar 2016, 22:45 (11 years ago) parent9aa47b5
3 files changed+9−14
wai-app-static/WaiAppStatic/Storage/Embedded/Runtime.hs+2−3 wai-app-static/WaiAppStatic/Storage/Filesystem.hs+5−6 wai-app-static/wai-app-static.cabal+2−5
wai-app-static/WaiAppStatic/Storage/Embedded/Runtime.hs+2−3
@@ -16,8 +16,7 @@ import qualified Data.Text as T
1616import Data.Ord
1717import qualified Data.ByteString as S
1818import Crypto.Hash (hash, MD5, Digest)
19−import Data.Byteable (toBytes)
20−import qualified Data.ByteString.Base64 as B64
19+import Data.ByteArray.Encoding
2120import WaiAppStatic.Storage.Filesystem (defaultFileServerSettings)
2221import System.FilePath (isPathSeparator)
2322
@@ -95,4 +94,4 @@ bsToFile name bs = File
9594 }
9695
9796runHash :: ByteString -> ByteString
98−runHash = B64.encode . toBytes . (hash :: S.ByteString -> Digest MD5)
97+runHash = convertToBase Base64 . (hash :: S.ByteString -> Digest MD5)
wai-app-static/WaiAppStatic/Storage/Filesystem.hs+5−6
@@ -23,10 +23,9 @@ import WaiAppStatic.Listing
2323import Network.Mime
2424import System.PosixCompat.Files (fileSize, getFileStatus, modificationTime, isRegularFile)
2525import Data.Maybe (catMaybes)
26−import qualified Crypto.Hash.Conduit (hashFile)
27−import Data.Byteable (toBytes)
28−import Crypto.Hash (MD5, Digest)
29−import qualified Data.ByteString.Base64 as B64
26+import Data.ByteArray.Encoding
27+import Crypto.Hash (hashlazy, MD5, Digest)
28+import qualified Data.ByteString.Lazy as BL (readFile)
3029import qualified Data.Text as T
3130
3231-- | Construct a new path from a root and some @Pieces@.
@@ -120,8 +119,8 @@ webAppLookup hashFunc prefix pieces =
120119-- exists.
121120hashFile :: FilePath -> IO ByteString
122121hashFile fp = do
123− h <- Crypto.Hash.Conduit.hashFile fp
124− return $ B64.encode $ toBytes (h :: Digest MD5)
122+ f <- BL.readFile fp
123+ return $ convertToBase Base64 (hashlazy f :: Digest MD5)
125124
126125hashFileIfExists :: ETagLookup
127126hashFileIfExists fp = do
wai-app-static/wai-app-static.cabal+2−5
@@ -38,9 +38,8 @@ library
3838 , file-embed >= 0.0.3.1
3939 , text >= 0.7
4040 , blaze-builder >= 0.2.1.4
41− , base64-bytestring >= 0.1
42− , byteable
43− , cryptohash >= 0.11
41+ , cryptonite >= 0.10
42+ , memory >= 0.10
4443 , http-date
4544 , blaze-html >= 0.5
4645 , blaze-markup >= 0.5.1
@@ -52,8 +51,6 @@ library
5251 , wai-extra >= 3.0 && < 3.1
5352 , optparse-applicative >= 0.7
5453 , warp >= 3.0.11 && < 3.3
55− -- Used exclusively for hashFile function
56− , cryptohash-conduit
5754
5855 exposed-modules: Network.Wai.Application.Static
5956 WaiAppStatic.Storage.Filesystem