packages feed

yesod-static 0.3.1 → 0.3.1.1

raw patch · 2 files changed

+26/−9 lines, 2 filesdep +enumerator

Dependencies added: enumerator

Files

Yesod/Static.hs view
@@ -65,6 +65,9 @@ import Network.HTTP.Types (status301) import System.PosixCompat.Files (getFileStatus, modificationTime) import System.Posix.Types (EpochTime)+import qualified Data.Enumerator as E+import qualified Data.Enumerator.List as EL+import qualified Data.Enumerator.Binary as EB  import Network.Wai.Application.Static     ( StaticSettings (..)@@ -271,22 +274,35 @@                 ]             ] +-- don't use L.readFile here, since it doesn't close handles quickly enough if+-- there are lots of files in the static folder, it will cause exhausted file+-- descriptors base64md5File :: Prelude.FilePath -> IO String base64md5File file = do-  contents <- L.readFile file-  return $ base64md5 contents+    bss <- E.run_ $ EB.enumFile file E.$$ EL.consume+    return $ base64md5 $ L.fromChunks bss+    -- FIXME I'd like something streaming instead+    {-+    fmap (base64 . finalize) $ E.run_ $+    EB.enumFile file E.$$ EL.fold go (md5InitialContext, "")+  where+    go (context, prev) next = (md5Update context prev, next)+    finalize (context, end) = md5Finalize context end+    -}  -- | md5-hashes the given lazy bytestring and returns the hash as -- base64url-encoded string. -- -- This function returns the first 8 characters of the hash. base64md5 :: L.ByteString -> String-base64md5 = map tr-          . take 8-          . S8.unpack-          . Data.ByteString.Base64.encode-          . Data.Serialize.encode-          . md5+base64md5 = base64 . md5++base64 :: MD5Digest -> String+base64 = map tr+       . take 8+       . S8.unpack+       . Data.ByteString.Base64.encode+       . Data.Serialize.encode   where     tr '+' = '-'     tr '/' = '_'
yesod-static.cabal view
@@ -1,5 +1,5 @@ name:            yesod-static-version:         0.3.1+version:         0.3.1.1 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -36,6 +36,7 @@                    , file-embed                >= 0.0.4.1  && < 0.5                    , http-types                >= 0.6.5    && < 0.7                    , unix-compat               >= 0.2      && < 0.3+                   , enumerator                >= 0.4.14   && < 0.5     exposed-modules: Yesod.Static     ghc-options:     -Wall