summaryrefslogtreecommitdiff
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
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.
-rw-r--r--Backend/Hash.hs23
-rw-r--r--Utility/ExternalSHA.hs2
-rw-r--r--debian/changelog3
-rw-r--r--doc/bugs/git_annex_fsck_on_btrfs_devices.mdwn4
4 files changed, 21 insertions, 11 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)
diff --git a/Utility/ExternalSHA.hs b/Utility/ExternalSHA.hs
index 3238c4733..e581697ae 100644
--- a/Utility/ExternalSHA.hs
+++ b/Utility/ExternalSHA.hs
@@ -21,8 +21,6 @@ import Utility.Exception
import Data.List
import Data.Char
import System.IO
-import Control.Applicative
-import Prelude
externalSHA :: String -> Int -> FilePath -> IO (Either String String)
externalSHA command shasize file = do
diff --git a/debian/changelog b/debian/changelog
index 4f05ca8ff..4508ab21a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ git-annex (5.20150523) UNRELEASED; urgency=medium
* Revert removal dependency on obsolete hamlet package, since the
autobuilders are not ready for this change yet and it prevented them
from building the webapp. Reopens: #786659
+ * 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.
-- Joey Hess <id@joeyh.name> Fri, 22 May 2015 22:23:32 -0400
diff --git a/doc/bugs/git_annex_fsck_on_btrfs_devices.mdwn b/doc/bugs/git_annex_fsck_on_btrfs_devices.mdwn
index 1ad2f65f9..7ed827b78 100644
--- a/doc/bugs/git_annex_fsck_on_btrfs_devices.mdwn
+++ b/doc/bugs/git_annex_fsck_on_btrfs_devices.mdwn
@@ -12,3 +12,7 @@ git-annex: sha1sum parse error
### What version of git-annex are you using? On what operating system?
git-annex 5.20150508
linux 4.0.4
+
+> [[fixed|done]]; IO errors are now detected and the file moved to bad/;
+> the fsck also continues past that failure now, so if a disk has
+> a lot of damanged files, it will find them all. --[[Joey]]