summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Fsck.hs35
-rw-r--r--doc/git-annex.mdwn8
2 files changed, 31 insertions, 12 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 1e49fd4d3..353fcb7b6 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -35,26 +35,41 @@ def = [withOptions options $ command "fsck" paramPaths seek
fromOption :: Option
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 = [fromOption]
+options = [fromOption, startIncrementalOption, incrementalOption]
seek :: [CommandSeek]
seek =
[ 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
]
-start :: Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
-start from file (key, backend) = do
+data Incremental = StartIncremental | ContIncremental | NonIncremental
+ deriving (Eq)
+
+start :: Maybe Remote -> Incremental -> FilePath -> (Key, Backend) -> CommandStart
+start from inc file (key, backend) = do
numcopies <- numCopies file
showStart "fsck" file
case from of
- Nothing -> next $ perform key file backend numcopies
- Just r -> next $ performRemote key file backend numcopies r
+ Nothing -> next $ perform inc key file backend numcopies
+ Just r -> next $ performRemote inc key file backend numcopies r
-perform :: Key -> FilePath -> Backend -> Maybe Int -> CommandPerform
-perform key file backend numcopies = check
+perform :: Incremental -> Key -> FilePath -> Backend -> Maybe Int -> CommandPerform
+perform inc key file backend numcopies = check
-- order matters
[ fixLink 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,
- and checked locally. -}
-performRemote :: Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform
-performRemote key file backend numcopies remote =
+performRemote :: Incremental -> Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform
+performRemote inc key file backend numcopies remote =
dispatch =<< Remote.hasKey remote key
where
dispatch (Left err) = do
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index ce7c0be3c..454dcf446 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -258,9 +258,13 @@ subdirectories).
With parameters, only the specified files are checked.
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
- fscking a remote), specify --fast
+ fscking a remote), specify --fast.
* unused