diff options
author | Joey Hess <joey@kitenet.net> | 2012-04-21 16:59:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-04-21 19:36:03 -0400 |
commit | b98b69e8c6d9b873a864b79cff857882f67ee576 (patch) | |
tree | 4ae145f9fe34c5e71424ab3d12dca6ab8070ce41 /Annex/Content.hs | |
parent | 7e45712d194aa2b231083c3ccee3668f053e5717 (diff) |
honor core.sharedRepository when making all the other files in the annex
Lock files, directories, etc.
Diffstat (limited to 'Annex/Content.hs')
-rw-r--r-- | Annex/Content.hs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index b216b861d..7022364d0 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -46,6 +46,7 @@ import Utility.CopyFile import Config import Annex.Exception import Git.SharedRepository +import Annex.Perms {- Checks if a given key's content is currently present. -} inAnnex :: Key -> Annex Bool @@ -141,7 +142,7 @@ getViaTmp key action = do prepTmp :: Key -> Annex FilePath prepTmp key = do tmp <- fromRepo $ gitAnnexTmpLocation key - liftIO $ createDirectoryIfMissing True (parentDir tmp) + createAnnexDirectory (parentDir tmp) return tmp {- Like getViaTmp, but does not check that there is enough disk space @@ -216,14 +217,11 @@ checkDiskSpace destination key alreadythere = do moveAnnex :: Key -> FilePath -> Annex () moveAnnex key src = do dest <- inRepo $ gitAnnexLocation key - let dir = parentDir dest ifM (liftIO $ doesFileExist dest) ( liftIO $ removeFile src , do - liftIO $ do - createDirectoryIfMissing True dir - allowWrite dir -- in case the directory already exists - moveFile src dest + createContentDir dest + liftIO $ moveFile src dest freezeContent dest freezeContentDir dest ) @@ -268,8 +266,8 @@ moveBad key = do src <- inRepo $ gitAnnexLocation key bad <- fromRepo gitAnnexBadDir let dest = bad </> takeFileName src + createAnnexDirectory (parentDir dest) liftIO $ do - createDirectoryIfMissing True (parentDir dest) allowWrite (parentDir src) moveFile src dest cleanObjectLoc key @@ -367,3 +365,13 @@ freezeContentDir file = liftIO . go =<< fromRepo getSharedRepository go AllShared = groupWriteRead dir go _ = preventWrite dir +{- Makes the directory tree to store an annexed file's content, + - with appropriate permissions on each level. -} +createContentDir :: FilePath -> Annex () +createContentDir dest = do + unlessM (liftIO $ doesDirectoryExist dir) $ + createAnnexDirectory dir + -- might have already existed with restricted perms + liftIO $ allowWrite dir + where + dir = parentDir dest |