From 849dba8bd97e054c3604c46ad7ab447277099310 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 26 Feb 2016 14:04:10 -0400 Subject: try again at forcing file read while hashing --- Backend/Hash.hs | 9 +++++++-- 1 file 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 -- cgit v1.2.3