diff options
author | Joey Hess <joey@kitenet.net> | 2012-04-21 19:42:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-04-21 19:42:49 -0400 |
commit | cab63b89f2470d0874e72a4a9e088206fb554c94 (patch) | |
tree | c55bacd12c0d8329e932458a94a808adac332ba5 /Annex | |
parent | b98b69e8c6d9b873a864b79cff857882f67ee576 (diff) |
cache parsed core.sharedrepository
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Perms.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Annex/Perms.hs b/Annex/Perms.hs index 2b54077ca..12dfdd667 100644 --- a/Annex/Perms.hs +++ b/Annex/Perms.hs @@ -15,15 +15,24 @@ module Annex.Perms ( import Common.Annex import Utility.FileMode import Git.SharedRepository +import qualified Annex import System.Posix.Types +withShared :: (SharedRepository -> Annex a) -> Annex a +withShared a = maybe startup a =<< Annex.getState Annex.shared + where + startup = do + shared <- fromRepo getSharedRepository + Annex.changeState $ \s -> s { Annex.shared = Just shared } + a shared + {- Sets appropriate file mode for a file or directory in the annex, - other than the content files and content directory. Normally, - use the default mode, but with core.sharedRepository set, - allow the group to write, etc. -} setAnnexPerm :: FilePath -> Annex () -setAnnexPerm file = liftIO . go =<< fromRepo getSharedRepository +setAnnexPerm file = withShared $ liftIO . go where go GroupShared = groupWriteRead file go AllShared = modifyFileMode file $ addModes $ @@ -33,7 +42,7 @@ setAnnexPerm file = liftIO . go =<< fromRepo getSharedRepository {- Gets the appropriate mode to use for creating a file in the annex - (other than content files, which are locked down more). -} annexFileMode :: Annex FileMode -annexFileMode = go <$> fromRepo getSharedRepository +annexFileMode = withShared $ return . go where go GroupShared = sharedmode go AllShared = combineModes (sharedmode:readModes) |