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.
This commit is contained in:
Joey Hess 2016-01-06 22:09:36 -04:00
parent 2e071a09b7
commit 7482853ddd
Failed to extract signature

View file

@ -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