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.
This commit is contained in:
parent
ff629a1ec0
commit
8990d4cc68
4 changed files with 21 additions and 11 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue