diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-26 14:04:10 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-26 14:04:10 -0400 |
commit | 849dba8bd97e054c3604c46ad7ab447277099310 (patch) | |
tree | 579465b705f6a40d7bcad6d69dd7db0db7ec005e | |
parent | ab71eec1033aa7af610c1b4206d2dbf64e5c1e68 (diff) |
try again at forcing file read while hashing
-rw-r--r-- | Backend/Hash.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs index ee370f5b1..c190f5477 100644 --- a/Backend/Hash.hs +++ b/Backend/Hash.hs @@ -5,7 +5,7 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, BangPatterns #-} module Backend.Hash ( backends, @@ -170,7 +170,12 @@ hashFile hash file filesize = go hash go (SHA3Hash hashsize) = use (sha3Hasher hashsize) go (SkeinHash hashsize) = use (skeinHasher hashsize) - use hasher = liftIO $ hasher <$> L.readFile file + use hasher = liftIO $ do + hdl <- openBinaryFile file ReadMode + b <- L.hGetContents hdl + let !hsh = hasher b + hClose hdl + return hsh usehasher hashsize = case shaHasher hashsize filesize of Left sha -> use sha |