summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-19 15:04:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-19 15:04:24 -0400
commitbbb2b798aec645f0c0754a5fb4e2fe8a126e2fd4 (patch)
tree5ed2e57712d389841257462d1057e9689905fb58 /Annex
parent11c97d173423bd5d3320124670ccc3b4c8675c06 (diff)
better memoize core.sharedrepository handling
It was memoized, but that was not used consistently. Move it to Types.GitConfig so it will auto-memoize.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Content.hs24
-rw-r--r--Annex/Perms.hs16
2 files changed, 18 insertions, 22 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index 379ff0785..c19fc29c0 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -614,39 +614,39 @@ preseedTmp key file = go =<< inAnnex key
- allow reading it, per core.sharedRepository setting. -}
freezeContent :: FilePath -> Annex ()
freezeContent file = unlessM crippledFileSystem $
- liftIO . go =<< fromRepo getSharedRepository
+ withShared go
where
- go GroupShared = modifyFileMode file $
+ go GroupShared = liftIO $ modifyFileMode file $
removeModes writeModes .
addModes [ownerReadMode, groupReadMode]
- go AllShared = modifyFileMode file $
+ go AllShared = liftIO $ modifyFileMode file $
removeModes writeModes .
addModes readModes
- go _ = modifyFileMode file $
+ go _ = liftIO $ modifyFileMode file $
removeModes writeModes .
addModes [ownerReadMode]
{- Adjusts read mode of annexed file per core.sharedRepository setting. -}
chmodContent :: FilePath -> Annex ()
chmodContent file = unlessM crippledFileSystem $
- liftIO . go =<< fromRepo getSharedRepository
+ withShared go
where
- go GroupShared = modifyFileMode file $
+ go GroupShared = liftIO $ modifyFileMode file $
addModes [ownerReadMode, groupReadMode]
- go AllShared = modifyFileMode file $
+ go AllShared = liftIO $ modifyFileMode file $
addModes readModes
- go _ = modifyFileMode file $
+ go _ = liftIO $ modifyFileMode file $
addModes [ownerReadMode]
{- Allows writing to an annexed file that freezeContent was called on
- before. -}
thawContent :: FilePath -> Annex ()
thawContent file = unlessM crippledFileSystem $
- liftIO . go =<< fromRepo getSharedRepository
+ withShared go
where
- go GroupShared = groupWriteRead file
- go AllShared = groupWriteRead file
- go _ = allowWrite file
+ go GroupShared = liftIO $ groupWriteRead file
+ go AllShared = liftIO $ groupWriteRead file
+ go _ = liftIO $ allowWrite file
{- Finds files directly inside a directory like gitAnnexBadDir
- (not in subdirectories) and returns the corresponding keys. -}
diff --git a/Annex/Perms.hs b/Annex/Perms.hs
index 06971173f..f32594ac3 100644
--- a/Annex/Perms.hs
+++ b/Annex/Perms.hs
@@ -15,6 +15,7 @@ module Annex.Perms (
freezeContentDir,
thawContentDir,
modifyContent,
+ withShared,
) where
import Common.Annex
@@ -26,12 +27,7 @@ import Config
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
+withShared a = a =<< coreSharedRepository <$> Annex.getGitConfig
setAnnexFilePerm :: FilePath -> Annex ()
setAnnexFilePerm = setAnnexPerm False
@@ -90,12 +86,12 @@ createAnnexDirectory dir = walk dir [] =<< top
-}
freezeContentDir :: FilePath -> Annex ()
freezeContentDir file = unlessM crippledFileSystem $
- liftIO . go =<< fromRepo getSharedRepository
+ withShared go
where
dir = parentDir file
- go GroupShared = groupWriteRead dir
- go AllShared = groupWriteRead dir
- go _ = preventWrite dir
+ go GroupShared = liftIO $ groupWriteRead dir
+ go AllShared = liftIO $ groupWriteRead dir
+ go _ = liftIO $ preventWrite dir
thawContentDir :: FilePath -> Annex ()
thawContentDir file = unlessM crippledFileSystem $