better forcing of hash

This commit is contained in:
Joey Hess 2016-02-26 16:36:24 -04:00
parent facc50d965
commit ac8af8da07
Failed to extract signature

View file

@ -171,11 +171,9 @@ hashFile hash file filesize = go hash
go (SkeinHash hashsize) = use (skeinHasher hashsize) go (SkeinHash hashsize) = use (skeinHasher hashsize)
use hasher = liftIO $ do use hasher = liftIO $ do
hdl <- openBinaryFile file ReadMode h <- hasher <$> L.readFile file
b <- L.hGetContents hdl -- Force full evaluation so file is read and closed.
let !hsh = hasher b return (length h `seq` h)
hClose hdl
return hsh
usehasher hashsize = case shaHasher hashsize filesize of usehasher hashsize = case shaHasher hashsize filesize of
Left sha -> use sha Left sha -> use sha