diff options
Diffstat (limited to 'Backend/Hash.hs')
-rw-r--r-- | Backend/Hash.hs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Backend/Hash.hs b/Backend/Hash.hs index fd89198d2..ed9553b7c 100644 --- a/Backend/Hash.hs +++ b/Backend/Hash.hs @@ -95,16 +95,17 @@ selectExtension f {- A key's checksum is checked during fsck. -} checkKeyChecksum :: Hash -> Key -> FilePath -> Annex Bool -checkKeyChecksum hash key file = do - fast <- Annex.getState Annex.fast - mstat <- liftIO $ catchMaybeIO $ getFileStatus file - case (mstat, fast) of - (Just stat, False) -> do - filesize <- liftIO $ getFileSize' file stat - showSideAction "checksum" - check <$> hashFile hash file filesize - _ -> return True +checkKeyChecksum hash key file = go `catchHardwareFault` hwfault 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 + showSideAction "checksum" + check <$> hashFile hash file filesize + _ -> return True expected = keyHash key check s | s == expected = True @@ -114,6 +115,10 @@ checkKeyChecksum hash key file = do | '\\' : s == expected = True | otherwise = False + hwfault e = do + warning $ "hardware fault: " ++ show e + return False + keyHash :: Key -> String keyHash key = dropExtensions (keyName key) |