From aff4d31f8f8132d06a76bb311093efed3af7bedb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 4 Jan 2018 14:46:58 -0400 Subject: more core.sharedRepository perm fixes Fix more places where files in .git/annex/ were written with modes that did not take the core.sharedRepository config into account. This commit was sponsored by Jeff Goeke-Smith on Patreon. --- Annex/Branch.hs | 8 ++++---- Annex/Content/Direct.hs | 3 ++- Logs/File.hs | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 6cb279702..2c7683e9e 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -57,6 +57,7 @@ import Annex.CatFile import Annex.Perms import Logs import Logs.Transitions +import Logs.File import Logs.Trust.Pure import Logs.Difference.Pure import Annex.ReplaceFile @@ -420,8 +421,7 @@ needUpdateIndex branchref = do setIndexSha :: Git.Ref -> Annex () setIndexSha ref = do f <- fromRepo gitAnnexIndexStatus - liftIO $ writeFile f $ fromRef ref ++ "\n" - setAnnexFilePerm f + writeLogFile f $ fromRef ref ++ "\n" runAnnexHook postUpdateAnnexHook {- Stages the journal into the index and returns an action that will @@ -583,7 +583,7 @@ ignoreRefs rs = do old <- getIgnoredRefs let s = S.unions [old, S.fromList rs] f <- fromRepo gitAnnexIgnoredRefs - replaceFile f $ \tmp -> liftIO $ writeFile tmp $ + writeLogFile f $ unlines $ map fromRef $ S.elems s getIgnoredRefs :: Annex (S.Set Git.Sha) @@ -600,7 +600,7 @@ addMergedRefs new = do -- Keep only the newest sha for each branch. let l = nubBy ((==) `on` snd) (new ++ old) f <- fromRepo gitAnnexMergedRefs - replaceFile f $ \tmp -> liftIO $ writeFile tmp $ + writeLogFile f $ unlines $ map (\(s, b) -> fromRef s ++ '\t' : fromRef b) l getMergedRefs :: Annex (S.Set Git.Sha) diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs index 734a0c1b9..98323b2b8 100644 --- a/Annex/Content/Direct.hs +++ b/Annex/Content/Direct.hs @@ -34,6 +34,7 @@ import Annex.Perms import qualified Git import Utility.Tmp import Logs.Location +import Logs.File import Utility.InodeCache import Utility.CopyFile import Annex.ReplaceFile @@ -67,7 +68,7 @@ changeAssociatedFiles key transform = do let files' = transform files when (files /= files') $ modifyContent mapping $ - liftIO $ viaTmp writeFile mapping $ unlines files' + writeLogFile mapping $ unlines files' top <- fromRepo Git.repoPath return $ map (top ) files' diff --git a/Logs/File.hs b/Logs/File.hs index c93b21e4d..6676dbb7e 100644 --- a/Logs/File.hs +++ b/Logs/File.hs @@ -11,6 +11,9 @@ import Annex.Common import Annex.Perms import Utility.Tmp +-- | Writes content to a file, replacing the file atomically, and +-- making the new file have whatever permissions the git repository is +-- configured to use. Creates the parent directory when necessary. writeLogFile :: FilePath -> String -> Annex () writeLogFile f c = go `catchNonAsync` \_e -> do -- Most of the time, the directory will exist, so this is only -- cgit v1.2.3