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.
This commit is contained in:
Joey Hess 2013-06-24 16:26:00 -04:00
parent ce9be5ec14
commit a35bdcb3f2
2 changed files with 18 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command {- 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. - Licensed under the GNU GPL version 3 or higher.
-} -}
@ -20,6 +20,7 @@ import qualified Types.Key
import qualified Backend import qualified Backend
import Annex.Content import Annex.Content
import Annex.Content.Direct import Annex.Content.Direct
import Annex.Direct
import Annex.Perms import Annex.Perms
import Annex.Link import Annex.Link
import Logs.Location import Logs.Location
@ -120,6 +121,7 @@ perform key file backend numcopies = check
[ fixLink key file [ fixLink key file
, verifyLocationLog key file , verifyLocationLog key file
, verifyDirectMapping key file , verifyDirectMapping key file
, verifyDirectMode key file
, checkKeySize key , checkKeySize key
, checkBackend backend key (Just file) , checkBackend backend key (Just file)
, checkKeyNumCopies key file numcopies , checkKeyNumCopies key file numcopies
@ -275,6 +277,20 @@ verifyDirectMapping key file = do
void $ removeAssociatedFile key f void $ removeAssociatedFile key f
return True 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 size of the data for a key is checked against the size encoded in
- the key's metadata, if available. - the key's metadata, if available.
- -

1
debian/changelog vendored
View file

@ -4,6 +4,7 @@ git-annex (4.20130622) UNRELEASED; urgency=low
* assistant: Daily sanity check thread is run niced. * assistant: Daily sanity check thread is run niced.
* bup: Handle /~/ in bup remote paths. * bup: Handle /~/ in bup remote paths.
Thanks, Oliver Matthews Thanks, Oliver Matthews
* fsck: Ensures that direct mode is used for files when it's enabled.
-- Joey Hess <joeyh@debian.org> Fri, 21 Jun 2013 13:16:17 -0400 -- Joey Hess <joeyh@debian.org> Fri, 21 Jun 2013 13:16:17 -0400