From 2bba5bc22d049272d3328bfa6c452d3e2e50e86c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Jan 2015 18:29:07 -0400 Subject: 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. --- Utility/Daemon.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Utility/Daemon.hs') diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index d1f539e98..961b098dc 100644 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -83,7 +83,7 @@ foreground pidfile a = do - Fails if the pid file is already locked by another process. -} lockPidFile :: FilePath -> IO () lockPidFile pidfile = do - createDirectoryIfMissing True (parentDir pidfile) + createDirectoryIfMissing True (takeDirectory pidfile) #ifndef mingw32_HOST_OS fd <- openFd pidfile ReadWrite (Just stdFileMode) defaultFileFlags locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0) @@ -176,6 +176,6 @@ winLockFile pid pidfile = do prefix = pidfile ++ "." suffix = ".lck" cleanstale = mapM_ (void . tryIO . removeFile) =<< - (filter iswinlockfile <$> dirContents (parentDir pidfile)) + (filter iswinlockfile <$> dirContents (takeDirectory pidfile)) iswinlockfile f = suffix `isSuffixOf` f && prefix `isPrefixOf` f #endif -- cgit v1.2.3