diff options
-rw-r--r-- | Annex.hs | 3 | ||||
-rw-r--r-- | Annex/Perms.hs | 13 |
2 files changed, 14 insertions, 2 deletions
@@ -37,6 +37,7 @@ import qualified Git import qualified Git.Config import Git.CatFile import Git.CheckAttr +import Git.SharedRepository import qualified Git.Queue import Types.Backend import qualified Types.Remote @@ -88,6 +89,7 @@ data AnnexState = AnnexState , forcebackend :: Maybe String , forcenumcopies :: Maybe Int , limit :: Matcher (FilePath -> Annex Bool) + , shared :: Maybe SharedRepository , forcetrust :: TrustMap , trustmap :: Maybe TrustMap , ciphers :: M.Map EncryptedCipher Cipher @@ -113,6 +115,7 @@ newState gitrepo = AnnexState , forcebackend = Nothing , forcenumcopies = Nothing , limit = Left [] + , shared = Nothing , forcetrust = M.empty , trustmap = Nothing , ciphers = M.empty 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) |