git-annex/Command/Fsck.hs

33 lines
794 B
Haskell
Raw Normal View History

2010-11-06 17:06:19 -04:00
{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Fsck where
import Command
2010-11-15 18:22:50 -04:00
import qualified Backend
import Types
import Messages
import Utility
2010-11-06 17:06:19 -04:00
2010-11-11 18:54:52 -04:00
seek :: [SubCmdSeek]
2010-11-28 18:55:49 -04:00
seek = [withAll (withAttrFilesInGit "annex.numcopies") start]
2010-11-15 18:22:50 -04:00
{- Checks a file's backend data for problems. -}
start :: SubCmdStartAttrFile
start (file, attr) = isAnnexed file $ \(key, backend) -> do
2010-11-15 18:22:50 -04:00
showStart "fsck" file
return $ Just $ perform key backend numcopies
where
numcopies = readMaybe attr :: Maybe Int
2010-11-15 18:22:50 -04:00
perform :: Key -> Backend -> Maybe Int -> SubCmdPerform
perform key backend numcopies = do
success <- Backend.fsckKey backend key numcopies
2010-11-22 17:51:55 -04:00
if success
2010-11-15 18:22:50 -04:00
then return $ Just $ return True
else return Nothing