This commit is contained in:
Joey Hess 2020-03-06 11:40:20 -04:00
parent eaa49ab53d
commit 2f204b5d37
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 17 additions and 7 deletions

View file

@ -11,6 +11,7 @@ module Annex.Perms (
setAnnexDirPerm, setAnnexDirPerm,
annexFileMode, annexFileMode,
createAnnexDirectory, createAnnexDirectory,
createWorkTreeDirectory,
noUmask, noUmask,
freezeContent, freezeContent,
isContentWritePermOk, isContentWritePermOk,
@ -25,6 +26,7 @@ module Annex.Perms (
import Annex.Common import Annex.Common
import Utility.FileMode import Utility.FileMode
import Git
import Git.ConfigTypes import Git.ConfigTypes
import qualified Annex import qualified Annex
import Config import Config
@ -77,6 +79,20 @@ createAnnexDirectory dir = do
liftIO $ createDirectory p liftIO $ createDirectory p
setAnnexDirPerm p setAnnexDirPerm p
{- Create a directory in the git work tree, creating any parent
- directories up to the top of the work tree.
-
- Uses default permissions.
-}
createWorkTreeDirectory :: FilePath -> Annex ()
createWorkTreeDirectory dir = do
fromRepo repoWorkTree >>= liftIO . \case
Just wt -> createDirectoryUnder (fromRawFilePath wt) dir
-- Should never happen, but let whatever tries to write
-- to the directory be what throws an exception, as that
-- will be clearer than an exception from here.
Nothing -> noop
{- Normally, blocks writing to an annexed file, and modifies file {- Normally, blocks writing to an annexed file, and modifies file
- permissions to allow reading it. - permissions to allow reading it.
- -

View file

@ -35,13 +35,7 @@ replaceGitDirFile = replaceFile $ \dir -> do
{- replaceFile on a worktree file. -} {- replaceFile on a worktree file. -}
replaceWorkTreeFile :: FilePath -> (FilePath -> Annex a) -> Annex a replaceWorkTreeFile :: FilePath -> (FilePath -> Annex a) -> Annex a
replaceWorkTreeFile = replaceFile $ \dir -> replaceWorkTreeFile = replaceFile createWorkTreeDirectory
fromRepo repoWorkTree >>= liftIO . \case
Just wt -> createDirectoryUnder (fromRawFilePath wt) dir
-- Should never happen, but let the file move be what
-- throws an exception as that would more clearly indicate
-- the problem.
Nothing -> noop
{- Replaces a possibly already existing file with a new version, {- Replaces a possibly already existing file with a new version,
- atomically, by running an action. - atomically, by running an action.