From: Joey Hess Date: Sun, 6 Dec 2015 20:29:36 +0000 (-0400) Subject: avoid looping trying to make temp dir when the name is too long X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~322^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4591569607fb49d342d45493fd9d825fe335ac2e;p=git-annex.git 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. --- diff --git a/Utility/Tmp.hs b/Utility/Tmp.hs index de970fe56e..7e4db1101b 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