@@ -36,8 +36,9 @@ import Distribution.Client.DistDirLayout
3636 , DistDirParams (.. )
3737 )
3838import Distribution.Client.HashValue
39- ( hashValue
40- , showHashValueBase64
39+ ( readFileHashValue
40+ , showHashValue
41+ , truncateHash
4142 )
4243import Distribution.Client.HttpUtils
4344 ( HttpTransport
@@ -218,33 +219,18 @@ import qualified Text.Parsec as P
218219-- repl to deal with the fact that the repl is relative to the working directory and not
219220-- the project root.
220221
221- -- | Get the hash of a script's absolute path)
222- --
223- -- Two hashes will be the same as long as the absolute paths
224- -- are the same.
222+ -- | Get the hash of a script's contents.
225223getScriptHash :: FilePath -> IO String
226224getScriptHash script =
227- -- Base64 is shorter than Base16, which helps avoid long path issues on windows
228- -- but it can contain /'s which aren't valid in file paths so replace them with
229- -- %'s. 26 chars / 130 bits is enough to practically avoid collisions.
230- map (\ c -> if c == ' /' then ' %' else c)
231- . take 26
232- . showHashValueBase64
233- . hashValue
234- . fromString
235- <$> canonicalizePath script
225+ showHashValue
226+ . truncateHash 26
227+ <$> readFileHashValue script
236228
237229-- | Get the directory for caching a script build.
238- --
239- -- The only identity of a script is it's absolute path, so append the
240- -- hashed path to the @script-builds@ dir to get the cache directory.
241230getScriptCacheDirectory :: FilePath -> IO FilePath
242231getScriptCacheDirectory script = (</>) <$> defaultScriptBuildsDir <*> getScriptHash script
243232
244233-- | Get the directory for caching a script build and ensure it exists.
245- --
246- -- The only identity of a script is it's absolute path, so append the
247- -- hashed path to the @script-builds@ dir to get the cache directory.
248234ensureScriptCacheDirectory :: Verbosity -> FilePath -> IO FilePath
249235ensureScriptCacheDirectory verbosity script = do
250236 cacheDir <- getScriptCacheDirectory script
0 commit comments