From ed8d9fe3c9598080f041adffbaf717e8c1c230bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 24 Jun 2013 16:26:00 -0400 Subject: fsck: Ensures that direct mode is used for files when it's enabled. A common failure mode for direct mode has been for files to end up still stored in indirect mode. While I hope that doesn't happen anymore, fsck should deal with it. --- Command/Fsck.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Command/Fsck.hs') diff --git a/Command/Fsck.hs b/Command/Fsck.hs index b95ba7ff7..ce1a28989 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010-2011 Joey Hess + - Copyright 2010-2013 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} @@ -20,6 +20,7 @@ import qualified Types.Key import qualified Backend import Annex.Content import Annex.Content.Direct +import Annex.Direct import Annex.Perms import Annex.Link import Logs.Location @@ -120,6 +121,7 @@ perform key file backend numcopies = check [ fixLink key file , verifyLocationLog key file , verifyDirectMapping key file + , verifyDirectMode key file , checkKeySize key , checkBackend backend key (Just file) , checkKeyNumCopies key file numcopies @@ -275,6 +277,20 @@ verifyDirectMapping key file = do void $ removeAssociatedFile key f return True +{- Ensures that files whose content is available are in direct mode. -} +verifyDirectMode :: Key -> FilePath -> Annex Bool +verifyDirectMode key file = do + whenM (isDirect <&&> islink) $ do + v <- toDirectGen key file + case v of + Nothing -> noop + Just a -> do + showNote "fixing direct mode" + a + return True + where + islink = liftIO $ isSymbolicLink <$> getSymbolicLinkStatus file + {- The size of the data for a key is checked against the size encoded in - the key's metadata, if available. - -- cgit v1.2.3