on master help sign in
asset gathering not strict enough (#393)
edf569aDan Bornside
ChangeLog.md+1
@@ -7,6 +7,7 @@ This project's release branch is `master`. This log is written from the perspect
7* Fix crashes of Android apps on 32-bit ARM devices.
7* Fix crashes of Android apps on 32-bit ARM devices.
8* Provide a way to indicate acceptance of the Android SDK license by passing `config.android_sdk.accept_license = true;` in the arguments to the import of `.obelisk/impl` in the project's `default.nix`.
8* Provide a way to indicate acceptance of the Android SDK license by passing `config.android_sdk.accept_license = true;` in the arguments to the import of `.obelisk/impl` in the project's `default.nix`.
9* Add `COMPLETE` pragma to `(:/)`. Using this pattern synonym should no longer generate spurious warnings about non-exhaustive pattern matching.
9* Add `COMPLETE` pragma to `(:/)`. Using this pattern synonym should no longer generate spurious warnings about non-exhaustive pattern matching.
10+* Make asset path hashing strict (see `Obelisk.Asset.Gather`)
10
11
11## v0.1.0.0 - 2019-03-29
12## v0.1.0.0 - 2019-03-29
12
13
lib/asset/manifest/obelisk-asset-manifest.cabal+1
@@ -17,6 +17,7 @@ library
17 base
17 base
18 , bytestring
18 , bytestring
19 , containers
19 , containers
20+ , deepseq
20 , directory
21 , directory
21 , SHA
22 , SHA
22 , filepath
23 , filepath
lib/asset/manifest/src/Obelisk/Asset/Gather.hs+4−1
@@ -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
6 ) where
7 ) where
7
8
9+import Control.DeepSeq
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
51
54
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