add --incremental and --new options

Not yet used..
This commit is contained in:
Joey Hess 2012-09-25 13:19:05 -04:00
parent e91dd3b9a6
commit 9e54a29546
2 changed files with 31 additions and 12 deletions

View file

@ -35,26 +35,41 @@ def = [withOptions options $ command "fsck" paramPaths seek
fromOption :: Option fromOption :: Option
fromOption = Option.field ['f'] "from" paramRemote "check remote" fromOption = Option.field ['f'] "from" paramRemote "check remote"
startIncrementalOption :: Option
startIncrementalOption = Option.flag ['S'] "incremental" "start an incremental fsck"
incrementalOption :: Option
incrementalOption = Option.flag ['n'] "new" "continue an incremental fsck"
options :: [Option] options :: [Option]
options = [fromOption] options = [fromOption, startIncrementalOption, incrementalOption]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = seek =
[ withField fromOption Remote.byName $ \from -> [ withField fromOption Remote.byName $ \from ->
withFilesInGit $ whenAnnexed $ start from withFlag startIncrementalOption $ \startincremental ->
withFlag incrementalOption $ \incremental ->
withFilesInGit $ whenAnnexed $
start from $ case (startincremental, incremental) of
(False, False) -> NonIncremental
(True, _) -> StartIncremental
(False, True) -> ContIncremental
, withBarePresentKeys startBare , withBarePresentKeys startBare
] ]
start :: Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart data Incremental = StartIncremental | ContIncremental | NonIncremental
start from file (key, backend) = do deriving (Eq)
start :: Maybe Remote -> Incremental -> FilePath -> (Key, Backend) -> CommandStart
start from inc file (key, backend) = do
numcopies <- numCopies file numcopies <- numCopies file
showStart "fsck" file showStart "fsck" file
case from of case from of
Nothing -> next $ perform key file backend numcopies Nothing -> next $ perform inc key file backend numcopies
Just r -> next $ performRemote key file backend numcopies r Just r -> next $ performRemote inc key file backend numcopies r
perform :: Key -> FilePath -> Backend -> Maybe Int -> CommandPerform perform :: Incremental -> Key -> FilePath -> Backend -> Maybe Int -> CommandPerform
perform key file backend numcopies = check perform inc key file backend numcopies = check
-- order matters -- order matters
[ fixLink key file [ fixLink key file
, verifyLocationLog key file , verifyLocationLog key file
@ -65,8 +80,8 @@ perform key file backend numcopies = check
{- To fsck a remote, the content is retrieved to a tmp file, {- To fsck a remote, the content is retrieved to a tmp file,
- and checked locally. -} - and checked locally. -}
performRemote :: Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform performRemote :: Incremental -> Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform
performRemote key file backend numcopies remote = performRemote inc key file backend numcopies remote =
dispatch =<< Remote.hasKey remote key dispatch =<< Remote.hasKey remote key
where where
dispatch (Left err) = do dispatch (Left err) = do

View file

@ -258,9 +258,13 @@ subdirectories).
With parameters, only the specified files are checked. With parameters, only the specified files are checked.
To check a remote to fsck, specify --from. To check a remote to fsck, specify --from.
To start a new incremental fsck, specify --incremental. Then
the next time you fsck, you can specify --new to skip over
files that have already been checked, and continue where it left off.
To avoid expensive checksum calculations (and expensive transfers when To avoid expensive checksum calculations (and expensive transfers when
fscking a remote), specify --fast fscking a remote), specify --fast.
* unused * unused