make canCheckSymlink check in a parent directory if the directory DNE
This commit is contained in:
parent
b818337054
commit
95bfbcd3e3
1 changed files with 10 additions and 5 deletions
|
@ -134,6 +134,7 @@ checkRepositoryPath p = do
|
||||||
expandTilde home ('~':'/':path) = home </> path
|
expandTilde home ('~':'/':path) = home </> path
|
||||||
expandTilde _ path = path
|
expandTilde _ path = path
|
||||||
|
|
||||||
|
|
||||||
{- On first run, if run in the home directory, default to putting it in
|
{- On first run, if run in the home directory, default to putting it in
|
||||||
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
|
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
|
||||||
-
|
-
|
||||||
|
@ -350,9 +351,13 @@ canWrite dir = do
|
||||||
|
|
||||||
{- Checks if a directory is on a filesystem that supports symlinks. -}
|
{- Checks if a directory is on a filesystem that supports symlinks. -}
|
||||||
canMakeSymlink :: FilePath -> IO Bool
|
canMakeSymlink :: FilePath -> IO Bool
|
||||||
canMakeSymlink dir = catchBoolIO $ do
|
canMakeSymlink dir = ifM (doesDirectoryExist dir)
|
||||||
createSymbolicLink link link
|
( catchBoolIO $ test dir
|
||||||
removeLink link
|
, canMakeSymlink (parentDir dir)
|
||||||
return True
|
)
|
||||||
where
|
where
|
||||||
link = dir </> "delete.me"
|
test d = do
|
||||||
|
let link = d </> "delete.me"
|
||||||
|
createSymbolicLink link link
|
||||||
|
removeLink link
|
||||||
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue