summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-27 16:40:03 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-27 16:40:03 -0400
commit7439ae35d768c77d679cba04fb3fb07ac795ef83 (patch)
tree05d15238ade3430407529e54a37ae639e136769b /Backend
parentfbd5182829d570231f911cb5ac7919d6333ccddc (diff)
fsck: When checksumming a file fails due to a hardware fault, the file is now moved to the bad directory, and the fsck proceeds. Before, the fsck immediately failed.
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Hash.hs23
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)