diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-05-27 16:40:03 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-05-27 16:40:03 -0400 |
commit | 7439ae35d768c77d679cba04fb3fb07ac795ef83 (patch) | |
tree | 05d15238ade3430407529e54a37ae639e136769b /Backend | |
parent | fbd5182829d570231f911cb5ac7919d6333ccddc (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.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) |