summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:29:36 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-06 16:29:36 -0400
commite0d2d182d6b31a7d24333b147a721fdbf5b3941f (patch)
tree289c4a1878e59d8b48964804216804602a144ebc
parentcf258d958853d7a9925b3f7abf2b617c5b64499d (diff)
avoid looping trying to make temp dir when the name is too long
Only loop when directory creation fails due to the directory existing already.
-rw-r--r--Utility/Tmp.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Utility/Tmp.hs b/Utility/Tmp.hs
index de970fe56..7e4db1101 100644
--- a/Utility/Tmp.hs
+++ b/Utility/Tmp.hs
@@ -88,8 +88,9 @@ withTmpDirIn tmpdir template = bracketIO create remove
makenewdir (tmpdir </> template) (0 :: Int)
makenewdir t n = do
let dir = t ++ "." ++ show n
- either (const $ makenewdir t $ n + 1) (const $ return dir)
- =<< tryIO (createDirectory dir)
+ catchIOErrorType AlreadyExists (const $ makenewdir t $ n + 1) $ do
+ createDirectory dir
+ return dir
{- It's not safe to use a FilePath of an existing file as the template
- for openTempFile, because if the FilePath is really long, the tmpfile