packages feed

wai-app-static 3.1.4.1 → 3.1.5

raw patch · 5 files changed

+21/−19 lines, 5 filesdep +cryptonitedep +memorydep −base64-bytestringdep −byteabledep −cryptohash

Dependencies added: cryptonite, memory

Dependencies removed: base64-bytestring, byteable, cryptohash, cryptohash-conduit

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 3.1.5++* Switch to cryponite+ ## 3.1.4.1  * Support wai/warp 3.2
WaiAppStatic/Storage/Embedded/Runtime.hs view
@@ -16,8 +16,7 @@ import Data.Ord import qualified Data.ByteString as S import Crypto.Hash (hash, MD5, Digest)-import Data.Byteable (toBytes)-import qualified Data.ByteString.Base64 as B64+import Data.ByteArray.Encoding import WaiAppStatic.Storage.Filesystem (defaultFileServerSettings) import System.FilePath (isPathSeparator) @@ -50,7 +49,7 @@ toEntry :: (Piece, EmbeddedEntry) -> Either FolderName File toEntry (name, EEFolder{}) = Left name toEntry (name, EEFile bs) = Right File-    { fileGetSize = S.length bs+    { fileGetSize = fromIntegral $ S.length bs     , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs     , fileName = name     , fileGetHash = return $ Just $ runHash bs@@ -87,7 +86,7 @@  bsToFile :: Piece -> ByteString -> File bsToFile name bs = File-    { fileGetSize = S.length bs+    { fileGetSize = fromIntegral $ S.length bs     , fileToResponse = \s h -> W.responseBuilder s h $ fromByteString bs     , fileName = name     , fileGetHash = return $ Just $ runHash bs@@ -95,4 +94,4 @@     }  runHash :: ByteString -> ByteString-runHash = B64.encode . toBytes . (hash :: S.ByteString -> Digest MD5)+runHash = convertToBase Base64 . (hash :: S.ByteString -> Digest MD5)
WaiAppStatic/Storage/Filesystem.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE BangPatterns #-} -- | Access files on the filesystem. module WaiAppStatic.Storage.Filesystem     ( -- * Types@@ -12,6 +13,7 @@  import WaiAppStatic.Types import System.FilePath ((</>))+import System.IO (withBinaryFile, IOMode(..)) import System.Directory (doesFileExist, doesDirectoryExist, getDirectoryContents) import Data.List (foldl') import Control.Monad (forM)@@ -23,10 +25,9 @@ import Network.Mime import System.PosixCompat.Files (fileSize, getFileStatus, modificationTime, isRegularFile) import Data.Maybe (catMaybes)-import qualified Crypto.Hash.Conduit (hashFile)-import Data.Byteable (toBytes)-import Crypto.Hash (MD5, Digest)-import qualified Data.ByteString.Base64 as B64+import Data.ByteArray.Encoding+import Crypto.Hash (hashlazy, MD5, Digest)+import qualified Data.ByteString.Lazy as BL (hGetContents) import qualified Data.Text as T  -- | Construct a new path from a root and some @Pieces@.@@ -119,9 +120,10 @@ -- | MD5 hash and base64-encode the file contents. Does not check if the file -- exists. hashFile :: FilePath -> IO ByteString-hashFile fp = do-    h <- Crypto.Hash.Conduit.hashFile fp-    return $ B64.encode $ toBytes (h :: Digest MD5)+hashFile fp = withBinaryFile fp ReadMode $ \h -> do+    f <- BL.hGetContents h+    let !hash = hashlazy f :: Digest MD5+    return $ convertToBase Base64 hash  hashFileIfExists :: ETagLookup hashFileIfExists fp = do
WaiAppStatic/Types.hs view
@@ -79,7 +79,7 @@ -- | Information on an individual file. data File = File     { -- | Size of file in bytes-      fileGetSize :: Int+      fileGetSize :: Integer       -- | How to construct a WAI response for this file. Some files are stored       -- on the filesystem and can use @ResponseFile@, while others are stored       -- in memory and should use @ResponseBuilder@.
wai-app-static.cabal view
@@ -1,5 +1,5 @@ name:            wai-app-static-version:         3.1.4.1+version:         3.1.5 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -38,9 +38,8 @@                    , file-embed                >= 0.0.3.1                    , text                      >= 0.7                    , blaze-builder             >= 0.2.1.4-                   , base64-bytestring         >= 0.1-                   , byteable-                   , cryptohash                >= 0.11+                   , cryptonite                >= 0.6+                   , memory                    >= 0.7                    , http-date                    , blaze-html                >= 0.5                    , blaze-markup              >= 0.5.1@@ -52,8 +51,6 @@                    , wai-extra                 >= 3.0      && < 3.1                    , optparse-applicative      >= 0.7                    , warp                      >= 3.0.11   && < 3.3-                   -- Used exclusively for hashFile function-                   , cryptohash-conduit      exposed-modules: Network.Wai.Application.Static                      WaiAppStatic.Storage.Filesystem