@@ -1,10 +1,12 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2+{-# LANGUAGE BangPatterns #-}
2-- | Functions for collecting up files to be processed by the asset pipeline
3-- | Functions for collecting up files to be processed by the asset pipeline
3module Obelisk.Asset.Gather
4module Obelisk.Asset.Gather
4 ( gatherHashedPaths
5 ( gatherHashedPaths
5 , toHashedPath
6 , toHashedPath
8import Control.Monad (forM)
10import Control.Monad (forM)
9import Data.Bits
11import Data.Bits
10import qualified Data.ByteString.Lazy as LBS
12import qualified Data.ByteString.Lazy as LBS
@@ -47,7 +49,8 @@ toHashedPath root relativePath = do
47 contents <- LBS.readFile path
49 contents <- LBS.readFile path
48 let hashPrefix = T.unpack $ decodeUtf8 $ LBS.toStrict $ toNixBase32 $ bytestringDigest $ sha256 contents
50 let hashPrefix = T.unpack $ decodeUtf8 $ LBS.toStrict $ toNixBase32 $ bytestringDigest $ sha256 contents
49 (dir, filename) = splitFileName relativePath
51 (dir, filename) = splitFileName relativePath
50− return $ normalise $ dir </> (hashPrefix <> "-" <> filename)
52+ !hashedRelativePath = force $ normalise $ dir </> (hashPrefix <> "-" <> filename)
53+ return hashedRelativePath
52-- | Convert a ByteString to base 32 in the way that Nix does
55-- | Convert a ByteString to base 32 in the way that Nix does
53toNixBase32 :: LBS.ByteString -> LBS.ByteString
56toNixBase32 :: LBS.ByteString -> LBS.ByteString