generalize catchHardwareFault to catchIOErrorType

This commit is contained in:
Joey Hess 2015-12-06 16:26:38 -04:00
parent 99fa2b5716
commit a0fcb8ec93
Failed to extract signature
4 changed files with 19 additions and 19 deletions

View file

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