wai-app-static 3.1.9.1 → 3.2.0
raw patch · 7 files changed
+45/−17 lines, 7 filesdep +cryptondep +ramnew-uploader
Dependencies added: crypton, ram
Files
- ChangeLog.md +2/−3
- WaiAppStatic/CmdLine.hs +1/−1
- WaiAppStatic/Storage/Embedded/Runtime.hs +14/−2
- WaiAppStatic/Storage/Filesystem.hs +10/−0
- test/tests.hs +6/−0
- tests.hs +0/−6
- wai-app-static.cabal +12/−5
ChangeLog.md view
@@ -1,9 +1,8 @@ # wai-app-static changelog -## 3.1.9.1+## 3.2.0 -* Backported a patch to not need `crypton` as a dependency.- Instead, just depend on `base64-bytestring` and `cryptohash-md5`.+* Using "ram" instead of "memory". ## 3.1.9
WaiAppStatic/CmdLine.hs view
@@ -132,7 +132,7 @@ port (if noindex then "no" else show index) let middle =- gzip def{gzipFiles = GzipCompress}+ gzip defaultGzipSettings{gzipFiles = GzipCompress} . (if verbose then logStdout else id) . middleware clArgs runSettings
WaiAppStatic/Storage/Embedded/Runtime.hs view
@@ -17,8 +17,13 @@ import qualified Data.Text as T import qualified Network.Wai as W import WaiAppStatic.Types+#ifdef MIN_VERSION_crypton+import Crypto.Hash (hash, MD5, Digest)+import Data.ByteArray.Encoding+#else import Crypto.Hash.MD5 (hash) import Data.ByteString.Base64 (encode)+#endif import System.FilePath (isPathSeparator) import WaiAppStatic.Storage.Filesystem (defaultFileServerSettings) @@ -57,7 +62,7 @@ { fileGetSize = fromIntegral $ S.length bs , fileToResponse = \s h -> W.responseBuilder s h $ byteString bs , fileName = name- , fileGetHash = return $ Just $ encode $ hash bs+ , fileGetHash = return $ Just $ runHash bs , fileGetModified = Nothing } @@ -95,6 +100,13 @@ { fileGetSize = fromIntegral $ S.length bs , fileToResponse = \s h -> W.responseBuilder s h $ byteString bs , fileName = name- , fileGetHash = return $ Just $ encode $ hash bs+ , fileGetHash = return $ Just $ runHash bs , fileGetModified = Nothing }++runHash :: ByteString -> ByteString+#ifdef MIN_VERSION_crypton+runHash = convertToBase Base64 . (hash :: S.ByteString -> Digest MD5)+#else+runHash = encode . hash+#endif
WaiAppStatic/Storage/Filesystem.hs view
@@ -37,8 +37,13 @@ import Util import WaiAppStatic.Listing import WaiAppStatic.Types+#ifdef MIN_VERSION_crypton+import Data.ByteArray.Encoding+import Crypto.Hash (hashlazy, MD5, Digest)+#else import Data.ByteString.Base64 (encode) import Crypto.Hash.MD5 (hashlazy)+#endif import qualified Data.ByteString.Lazy as BL (hGetContents) import qualified Data.Text as T @@ -152,8 +157,13 @@ hashFile :: FilePath -> IO ByteString hashFile fp = withBinaryFile fp ReadMode $ \h -> do f <- BL.hGetContents h+#ifdef MIN_VERSION_crypton+ let !hash = hashlazy f :: Digest MD5+ return $ convertToBase Base64 hash+#else let !hash = hashlazy f return . encode $ hash+#endif hashFileIfExists :: ETagLookup hashFileIfExists fp = do
+ test/tests.hs view
@@ -0,0 +1,6 @@+import Test.Hspec+import WaiAppEmbeddedTest (embSpec)+import WaiAppStaticTest (spec)++main :: IO ()+main = hspec $ spec >> embSpec
− tests.hs
@@ -1,6 +0,0 @@-import Test.Hspec-import WaiAppEmbeddedTest (embSpec)-import WaiAppStaticTest (spec)--main :: IO ()-main = hspec $ spec >> embSpec
wai-app-static.cabal view
@@ -1,5 +1,5 @@ name: wai-app-static-version: 3.1.9.1+version: 3.2.0 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -14,9 +14,7 @@ Extra-source-files: images/folder.png images/haskell.png- test/*.hs test/a/b- tests.hs README.md ChangeLog.md @@ -24,6 +22,10 @@ Description: print debug info Default: False +Flag crypton+ Description: Use the crypton library for MD5 computation+ Default: True+ library default-language: Haskell2010 build-depends: base >= 4.12 && < 5@@ -49,7 +51,11 @@ , wai-extra >= 3.0 && < 3.2 , optparse-applicative >= 0.7 , warp >= 3.0.11 && < 3.5- , base64-bytestring >= 0.1+ if flag(crypton)+ build-depends: crypton >= 1.1.0 && < 1.2+ , ram >= 0.21+ else+ build-depends: base64-bytestring >= 0.1 , cryptohash-md5 >= 0.11.101 exposed-modules: Network.Wai.Application.Static@@ -79,7 +85,7 @@ other-modules: EmbeddedTestEntries , WaiAppEmbeddedTest , WaiAppStaticTest- main-is: ../tests.hs+ main-is: tests.hs type: exitcode-stdio-1.0 build-depends: base >= 4 && < 5@@ -103,3 +109,4 @@ source-repository head type: git location: https://github.com/yesodweb/wai.git+ subdir: wai-app-static