summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Fsck.hs42
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex.mdwn12
3 files changed, 51 insertions, 5 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 3f13140d0..479bca6ef 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -25,6 +25,7 @@ import Utility.FileMode
import Config
import qualified Option
import Types.Key
+import Utility.HumanTime
import System.Posix.Process (getProcessID)
import Data.Time.Clock.POSIX
@@ -45,8 +46,17 @@ startIncrementalOption = Option.flag ['S'] "incremental" "start an incremental f
moreIncrementalOption :: Option
moreIncrementalOption = Option.flag ['m'] "more" "continue an incremental fsck"
+incrementalRestartOption :: Option
+incrementalRestartOption = Option.field [] "incremental-restart" paramTime
+ "schedule an incremental fsck"
+
options :: [Option]
-options = [fromOption, startIncrementalOption, moreIncrementalOption]
+options =
+ [ fromOption
+ , startIncrementalOption
+ , moreIncrementalOption
+ , incrementalRestartOption
+ ]
seek :: [CommandSeek]
seek =
@@ -57,14 +67,33 @@ seek =
withIncremental :: (Incremental -> CommandSeek) -> CommandSeek
withIncremental = withValue $ do
+ i <- maybe (return False) (checkrestart . parseDuration)
+ =<< Annex.getField (Option.name incrementalRestartOption)
starti <- Annex.getFlag (Option.name startIncrementalOption)
morei <- Annex.getFlag (Option.name moreIncrementalOption)
- case (starti, morei) of
- (False, False) -> return NonIncremental
- (True, _) -> do
+ case (i, starti, morei) of
+ (False, False, False) -> return NonIncremental
+ (False, True, _) -> startIncremental
+ (False ,False, True) -> ContIncremental <$> getStartTime
+ (True, _, _) ->
+ maybe startIncremental (return . ContIncremental . Just)
+ =<< getStartTime
+ where
+ startIncremental = do
recordStartTime
return StartIncremental
- (False, True) -> ContIncremental <$> getStartTime
+
+ checkrestart Nothing = error "bad --incremental-restart value"
+ checkrestart (Just delta) = do
+ Annex.addCleanup "" $ do
+ v <- getStartTime
+ case v of
+ Nothing -> noop
+ Just started -> do
+ now <- liftIO getPOSIXTime
+ when (now - realToFrac started >= delta) $
+ resetStartTime
+ return True
start :: Maybe Remote -> Incremental -> FilePath -> (Key, Backend) -> CommandStart
start from inc file (key, backend) = do
@@ -389,6 +418,9 @@ recordStartTime = do
showTime :: POSIXTime -> String
showTime = show
+resetStartTime :: Annex ()
+resetStartTime = liftIO . nukeFile =<< fromRepo gitAnnexFsckState
+
{- Gets the incremental fsck start time. -}
getStartTime :: Annex (Maybe EpochTime)
getStartTime = do
diff --git a/debian/changelog b/debian/changelog
index acdbe24cc..a8a952b0a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ git-annex (3.20120925) UNRELEASED; urgency=low
Thanks, Justin Azoff
* New --time-limit option, makes long git-annex commands stop after
a specified amount of time.
+ * fsck: New --incremental-restart option which is nice for scheduling
+ eg, monthly incremental fsck runs in cron jobs.
-- Joey Hess <joeyh@debian.org> Mon, 24 Sep 2012 19:58:07 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index ffcfa1f3b..9b99ea284 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -266,6 +266,18 @@ subdirectories).
the next time you fsck, you can specify --more to skip over
files that have already been checked, and continue where it left off.
+ The --incremental-restart option makes a new incremental fsck be
+ started a configurable time after the last incremental fsck was started.
+ Note that the current incremental fsck has to completely finish
+ before the restart happens.
+
+ Maybe you'd like to run a fsck for 5 hours at night, picking up each
+ night where it left off. You'd like this to continue until all files
+ have been fscked. And once it's done, you'd like a new fsck pass to start,
+ but no more often than once a month. Then put this in a nightly cron job:
+
+ git annex fsck --incremental-restart 30d --time-limit 5h
+
* unused
Checks the annex for data that does not correspond to any files present