summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-26 16:36:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-26 16:36:24 -0400
commit889842ab3dbde74058b4fbbc8d8061d583c4778b (patch)
tree95c4fd40c4c35623b13ab33a2dc30fd7e169751b /Backend
parent3563c89a255fbe8cbc4932b1668a58a408b7d7e7 (diff)
better forcing of hash
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Hash.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs
index c190f5477..2835b5637 100644
--- a/Backend/Hash.hs
+++ b/Backend/Hash.hs
@@ -171,11 +171,9 @@ hashFile hash file filesize = go hash
go (SkeinHash hashsize) = use (skeinHasher hashsize)
use hasher = liftIO $ do
- hdl <- openBinaryFile file ReadMode
- b <- L.hGetContents hdl
- let !hsh = hasher b
- hClose hdl
- return hsh
+ h <- hasher <$> L.readFile file
+ -- Force full evaluation so file is read and closed.
+ return (length h `seq` h)
usehasher hashsize = case shaHasher hashsize filesize of
Left sha -> use sha