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.
This commit is contained in:
Joey Hess 2018-01-04 14:46:58 -04:00
parent 1825012e60
commit faf03ee4da
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 9 additions and 5 deletions

View file

@ -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)

View file

@ -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'

View file

@ -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