From 7439ae35d768c77d679cba04fb3fb07ac795ef83 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 May 2015 16:40:03 -0400 Subject: 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. --- Backend/Hash.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'Backend') 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) -- cgit v1.2.3