summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-06-24 16:26:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-06-24 16:26:00 -0400
commited8d9fe3c9598080f041adffbaf717e8c1c230bb (patch)
treeb22fa36f74c663985b7e5ada89f4098a3ea0cbbd /Command/Fsck.hs
parent3e5a73062097468c89f59835991654540a5addbf (diff)
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.
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs18
1 files changed, 17 insertions, 1 deletions
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 <joey@kitenet.net>
+ - Copyright 2010-2013 Joey Hess <joey@kitenet.net>
-
- 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.
-