diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-06 22:09:36 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-06 22:09:36 -0400 |
commit | d11b032bd86ebe69f1d08e382bd83370db8ea9b9 (patch) | |
tree | b0c6a9dacade47bd2b36a63fec2c209df4126c1e /Backend | |
parent | 17180e79e82f7346ff1120ba8d28ddd953b40bd5 (diff) |
force hash to finish with file before returning
Fixes a minor fd leak, never more than 1 in normal use,
which broke the test suite when I tried to write to
a file that was still open for a previous hashing.
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/Hash.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs index 7967b1714..77e964bad 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 BangPatterns, CPP #-} module Backend.Hash ( backends, @@ -171,7 +171,9 @@ 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 + !h <- hasher <$> L.readFile file + return h usehasher hashsize = case shaHasher hashsize filesize of Left sha -> use sha |