diff --git a/Annex.hs b/Annex.hs index 7fb8afd5c3..d314d3ec72 100644 --- a/Annex.hs +++ b/Annex.hs @@ -104,6 +104,7 @@ data AnnexState = AnnexState , uuidmap :: Maybe UUIDMap , preferredcontentmap :: Maybe PreferredContentMap , shared :: Maybe SharedRepository + , direct :: Maybe Bool , forcetrust :: TrustMap , trustmap :: Maybe TrustMap , groupmap :: Maybe GroupMap @@ -133,6 +134,7 @@ newState gitrepo = AnnexState , uuidmap = Nothing , preferredcontentmap = Nothing , shared = Nothing + , direct = Nothing , forcetrust = M.empty , trustmap = Nothing , groupmap = Nothing diff --git a/Config.hs b/Config.hs index 66b8dc124d..02cbb5e51e 100644 --- a/Config.hs +++ b/Config.hs @@ -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. -}