diff options
author | Joey Hess <joey@kitenet.net> | 2012-12-29 13:37:11 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-12-29 13:37:11 -0400 |
commit | 1b007068ca4936306889b8b3af2bf224746a2318 (patch) | |
tree | 1a6a2052aa3900c8d8f0d579b407349b57cd9015 /Config.hs | |
parent | 4d51b93a05dd6482a9ba364e23faa354f2d20997 (diff) |
memoize parsing of annex.direct config setting
It occurs to me that all config settings should be parsed once at startup,
into a proper ADT, rather than all this ad-hoc parsing and memoization. One
day..
Diffstat (limited to 'Config.hs')
-rw-r--r-- | Config.hs | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -116,13 +116,20 @@ getDiskReserve = fromMaybe megabyte . readSize dataUnits where megabyte = 1000000 -{- Gets annex.direct setting. -} +{- Gets annex.direct setting, cached for speed. -} isDirect :: Annex Bool -isDirect = fromMaybe False . Git.Config.isTrue <$> - getConfig (annexConfig "direct") "" +isDirect = maybe fromconfig return =<< Annex.getState Annex.direct + where + fromconfig = do + direct <- fromMaybe False . Git.Config.isTrue <$> + getConfig (annexConfig "direct") "" + Annex.changeState $ \s -> s { Annex.direct = Just direct } + return direct setDirect :: Bool -> Annex () -setDirect b = setConfig (annexConfig "direct") (if b then "true" else "false") +setDirect b = do + setConfig (annexConfig "direct") (if b then "true" else "false") + Annex.changeState $ \s -> s { Annex.direct = Just b } {- Gets annex.httpheaders or annex.httpheaders-command setting, - splitting it into lines. -} |