aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:26:38 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:26:38 -0400
commitcf258d958853d7a9925b3f7abf2b617c5b64499d (patch)
treea5c526d51aeaa18ca2e89558c46334fe372b4a22 /Backend
parent29fe475e490840ffa859b85258353c174b87ee4d (diff)
generalize catchHardwareFault to catchIOErrorType
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Hash.hs19
1 files changed, 9 insertions, 10 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs
index 7f61c4f3e..7967b1714 100644
--- a/Backend/Hash.hs
+++ b/Backend/Hash.hs
@@ -108,17 +108,16 @@ selectExtension f
{- A key's checksum is checked during fsck. -}
checkKeyChecksum :: Hash -> Key -> FilePath -> Annex Bool
-checkKeyChecksum hash key file = go `catchHardwareFault` hwfault
+checkKeyChecksum hash key file = catchIOErrorType HardwareFault hwfault $ do
+ fast <- Annex.getState Annex.fast
+ mstat <- liftIO $ catchMaybeIO $ getFileStatus file
+ case (mstat, fast) of
+ (Just stat, False) -> do
+ filesize <- liftIO $ getFileSize' file stat
+ showAction "checksum"
+ check <$> hashFile hash file filesize
+ _ -> return True
where
- go = do
- fast <- Annex.getState Annex.fast
- mstat <- liftIO $ catchMaybeIO $ getFileStatus file
- case (mstat, fast) of
- (Just stat, False) -> do
- filesize <- liftIO $ getFileSize' file stat
- showAction "checksum"
- check <$> hashFile hash file filesize
- _ -> return True
expected = keyHash key
check s
| s == expected = True