diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-16 16:17:20 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-16 16:20:30 -0400 |
commit | 0bb7e38c01fda96340b371081ac5a310f2712838 (patch) | |
tree | 43ac4c50e7eb6a66e8a9ba2a4a3266d7c9dc84b5 /Command | |
parent | 21d8cff6adf42043acaf90537e83c0ab5b357117 (diff) |
fsck: Check content of direct mode files (only when the inode cache thinks they are unmodified).
I wrote this earlier, but it never worked because it was looking at the
.git/annex/object content, which is not there..
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Fsck.hs | 26 | ||||
-rw-r--r-- | Command/Migrate.hs | 2 |
2 files changed, 15 insertions, 13 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 9a81f986b..1c9af0d34 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -112,7 +112,7 @@ perform key file backend numcopies = check , verifyLocationLog key file , verifyDirectMapping key file , checkKeySize key - , checkBackend backend key + , checkBackend backend key (Just file) , checkKeyNumCopies key file numcopies ] @@ -177,7 +177,7 @@ performBare :: Key -> Backend -> Annex Bool performBare key backend = check [ verifyLocationLog key (key2file key) , checkKeySize key - , checkBackend backend key + , checkBackend backend key Nothing ] check :: [Annex Bool] -> Annex Bool @@ -321,17 +321,19 @@ checkKeySizeOr bad key file = case Types.Key.keySize key of - because modification of direct mode files is allowed. It's still done - if the file does not appear modified, to catch disk corruption, etc. -} -checkBackend :: Backend -> Key -> Annex Bool -checkBackend backend key = do - file <- calcRepo $ gitAnnexLocation key - ifM isDirect - ( ifM (goodContent key file) - ( checkBackendOr' (badContentDirect file) backend key file - (goodContent key file) - , return True - ) - , checkBackendOr badContent backend key file +checkBackend :: Backend -> Key -> Maybe FilePath -> Annex Bool +checkBackend backend key mfile = go =<< isDirect + where + go False = do + content <- calcRepo $ gitAnnexLocation key + checkBackendOr badContent backend key content + go True = maybe nocheck checkdirect mfile + checkdirect file = ifM (goodContent key file) + ( checkBackendOr' (badContentDirect file) backend key file + (goodContent key file) + , nocheck ) + nocheck = return True checkBackendRemote :: Backend -> Key -> Remote -> Maybe FilePath -> Annex Bool checkBackendRemote backend key remote = maybe (return True) go diff --git a/Command/Migrate.hs b/Command/Migrate.hs index e0ef650b0..d8bfd74f1 100644 --- a/Command/Migrate.hs +++ b/Command/Migrate.hs @@ -55,7 +55,7 @@ upgradableKey backend key = isNothing (Types.Key.keySize key) || backendupgradab - be other files still pointing at that key. -} perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform perform file oldkey oldbackend newbackend = do - ifM (Command.Fsck.checkBackend oldbackend oldkey) + ifM (Command.Fsck.checkBackend oldbackend oldkey (Just file)) ( maybe stop go =<< genkey , stop ) |