summaryrefslogtreecommitdiff
path: root/Annex/Perms.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-01-06 18:29:07 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-01-06 18:55:56 -0400
commit2bba5bc22d049272d3328bfa6c452d3e2e50e86c (patch)
tree19feab50e43dc330038224ea98b371916ca02133 /Annex/Perms.hs
parent014e909a449d0822eff4962a504d6a524abe8fc7 (diff)
made parentDir return a Maybe FilePath; removed most uses of it
parentDir is less safe than takeDirectory, especially when working with relative FilePaths. It's really only useful in loops that want to terminate at / This commit was sponsored by Audric SCHILTKNECHT.
Diffstat (limited to 'Annex/Perms.hs')
-rw-r--r--Annex/Perms.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Annex/Perms.hs b/Annex/Perms.hs
index 3430554c7..d314e382c 100644
--- a/Annex/Perms.hs
+++ b/Annex/Perms.hs
@@ -71,12 +71,12 @@ annexFileMode = withShared $ return . go
createAnnexDirectory :: FilePath -> Annex ()
createAnnexDirectory dir = traverse dir [] =<< top
where
- top = parentDir <$> fromRepo gitAnnexDir
+ top = takeDirectory <$> fromRepo gitAnnexDir
traverse d below stop
| d `equalFilePath` stop = done
| otherwise = ifM (liftIO $ doesDirectoryExist d)
( done
- , traverse (parentDir d) (d:below) stop
+ , traverse (takeDirectory d) (d:below) stop
)
where
done = forM_ below $ \p -> do
@@ -92,14 +92,14 @@ freezeContentDir :: FilePath -> Annex ()
freezeContentDir file = unlessM crippledFileSystem $
liftIO . go =<< fromRepo getSharedRepository
where
- dir = parentDir file
+ dir = takeDirectory file
go GroupShared = groupWriteRead dir
go AllShared = groupWriteRead dir
go _ = preventWrite dir
thawContentDir :: FilePath -> Annex ()
thawContentDir file = unlessM crippledFileSystem $
- liftIO $ allowWrite $ parentDir file
+ liftIO $ allowWrite $ takeDirectory file
{- Makes the directory tree to store an annexed file's content,
- with appropriate permissions on each level. -}
@@ -111,7 +111,7 @@ createContentDir dest = do
unlessM crippledFileSystem $
liftIO $ allowWrite dir
where
- dir = parentDir dest
+ dir = takeDirectory dest
{- Creates the content directory for a file if it doesn't already exist,
- or thaws it if it does, then runs an action to modify the file, and