From 652f844e2348165062868cb197ee725d42198f03 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 29 Dec 2012 23:10:18 -0400 Subject: type based git config handling Now there's a Config type, that's extracted from the git config at startup. Note that laziness means that individual config values are only looked up and parsed on demand, and so we get implicit memoization for all of them. So this is not only prettier and more type safe, it optimises several places that didn't have explicit memoization before. As well as getting rid of the ugly explicit memoization code. Not yet done for annex..* configuration settings. --- Assistant/Threads/Committer.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Assistant') diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index e968959c6..7940b0836 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -32,6 +32,7 @@ import Types.KeySource import Config import Annex.Exception import Annex.Content +import qualified Annex import Data.Time.Clock import Data.Tuple.Utils @@ -41,9 +42,9 @@ import Data.Either {- This thread makes git commits at appropriate times. -} commitThread :: NamedThread commitThread = NamedThread "Committer" $ do - delayadd <- liftAnnex $ do - v <- readish <$> getConfig (annexConfig "delayadd") "" - maybe delayaddDefault (return . Just . Seconds) v + delayadd <- liftAnnex $ + maybe delayaddDefault (return . Just . Seconds) + =<< annexDelayAdd <$> Annex.getConfig runEvery (Seconds 1) <~> do -- We already waited one second as a simple rate limiter. -- Next, wait until at least one change is available for -- cgit v1.2.3