diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-01-06 18:29:07 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-01-06 18:55:56 -0400 |
commit | 2bba5bc22d049272d3328bfa6c452d3e2e50e86c (patch) | |
tree | 19feab50e43dc330038224ea98b371916ca02133 /Assistant | |
parent | 014e909a449d0822eff4962a504d6a524abe8fc7 (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 'Assistant')
-rw-r--r-- | Assistant/Install.hs | 4 | ||||
-rw-r--r-- | Assistant/Install/AutoStart.hs | 2 | ||||
-rw-r--r-- | Assistant/Install/Menu.hs | 2 | ||||
-rw-r--r-- | Assistant/Ssh.hs | 3 | ||||
-rw-r--r-- | Assistant/Threads/UpgradeWatcher.hs | 2 |
5 files changed, 7 insertions, 6 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs index e2d52692e..e30de173c 100644 --- a/Assistant/Install.hs +++ b/Assistant/Install.hs @@ -49,7 +49,7 @@ ensureInstalled = go =<< standaloneAppBase go (Just base) = do let program = base </> "git-annex" programfile <- programFile - createDirectoryIfMissing True (parentDir programfile) + createDirectoryIfMissing True (takeDirectory programfile) writeFile programfile program #ifdef darwin_HOST_OS @@ -87,7 +87,7 @@ installWrapper :: FilePath -> String -> IO () installWrapper file content = do curr <- catchDefaultIO "" $ readFileStrict file when (curr /= content) $ do - createDirectoryIfMissing True (parentDir file) + createDirectoryIfMissing True (takeDirectory file) viaTmp writeFile file content modifyFileMode file $ addModes [ownerExecuteMode] diff --git a/Assistant/Install/AutoStart.hs b/Assistant/Install/AutoStart.hs index b03d20224..7e0c7507b 100644 --- a/Assistant/Install/AutoStart.hs +++ b/Assistant/Install/AutoStart.hs @@ -19,7 +19,7 @@ import System.Directory installAutoStart :: FilePath -> FilePath -> IO () installAutoStart command file = do #ifdef darwin_HOST_OS - createDirectoryIfMissing True (parentDir file) + createDirectoryIfMissing True (takeDirectory file) writeFile file $ genOSXAutoStartFile osxAutoStartLabel command ["assistant", "--autostart"] #else diff --git a/Assistant/Install/Menu.hs b/Assistant/Install/Menu.hs index d095cdd88..15ef5534d 100644 --- a/Assistant/Install/Menu.hs +++ b/Assistant/Install/Menu.hs @@ -38,7 +38,7 @@ fdoDesktopMenu command = genDesktopEntry installIcon :: FilePath -> FilePath -> IO () installIcon src dest = do - createDirectoryIfMissing True (parentDir dest) + createDirectoryIfMissing True (takeDirectory dest) withBinaryFile src ReadMode $ \hin -> withBinaryFile dest WriteMode $ \hout -> hGetContents hin >>= hPutStr hout diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 7b82f4624..fa481a186 100644 --- a/Assistant/Ssh.hs +++ b/Assistant/Ssh.hs @@ -233,7 +233,8 @@ genSshKeyPair = withTmpDir "git-annex-keygen" $ \dir -> do setupSshKeyPair :: SshKeyPair -> SshData -> IO SshData setupSshKeyPair sshkeypair sshdata = do sshdir <- sshDir - createDirectoryIfMissing True $ parentDir $ sshdir </> sshprivkeyfile + createDirectoryIfMissing True $ + takeDirectory $ sshdir </> sshprivkeyfile unlessM (doesFileExist $ sshdir </> sshprivkeyfile) $ writeFileProtected (sshdir </> sshprivkeyfile) (sshPrivKey sshkeypair) diff --git a/Assistant/Threads/UpgradeWatcher.hs b/Assistant/Threads/UpgradeWatcher.hs index 431e6f339..401215999 100644 --- a/Assistant/Threads/UpgradeWatcher.hs +++ b/Assistant/Threads/UpgradeWatcher.hs @@ -47,7 +47,7 @@ upgradeWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do , modifyHook = changed , delDirHook = changed } - let dir = parentDir flagfile + let dir = takeDirectory flagfile let depth = length (splitPath dir) + 1 let nosubdirs f = length (splitPath f) == depth void $ liftIO $ watchDir dir nosubdirs False hooks (startup mvar) |