fsck: Detect and fix consistency errors in direct mode mapping files.

This commit is contained in:
Joey Hess 2013-01-19 14:11:23 -04:00
parent 4ca9b6bdcf
commit 672f8b5b83
2 changed files with 15 additions and 0 deletions

View file

@ -110,6 +110,7 @@ perform key file backend numcopies = check
-- order matters
[ fixLink key file
, verifyLocationLog key file
, verifyDirectMapping key file
, checkKeySize key
, checkBackend backend key
, checkKeyNumCopies key file numcopies
@ -258,6 +259,19 @@ verifyLocationLog' key desc present u bad = do
showNote "fixing location log"
bad s
{- Ensures the direct mode mapping file is consistent. Each file
- it lists for the key should exist, and the specified file should be
- included in it.
-}
verifyDirectMapping :: Key -> FilePath -> Annex Bool
verifyDirectMapping key file = do
whenM isDirect $ do
fs <- addAssociatedFile key file
forM_ fs $ \f ->
unlessM (liftIO $ doesFileExist f) $
void $ removeAssociatedFile key f
return True
{- The size of the data for a key is checked against the size encoded in
- the key's metadata, if available.
-