diff options
author | Joey Hess <joey@kitenet.net> | 2014-01-13 18:10:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-01-13 18:10:21 -0400 |
commit | 14ce1badd4210ebb2660e0fb22ba4ff7f2986dee (patch) | |
tree | a0eb1548d7d879631cef51266e8f2ee65fa7a66f /Utility/Tmp.hs | |
parent | dd1d8e69d4c190c7bb60d5187f7a889c6fea0d62 (diff) | |
download | git-repair-14ce1badd4210ebb2660e0fb22ba4ff7f2986dee.tar.gz |
merge from git-annex
Diffstat (limited to 'Utility/Tmp.hs')
-rw-r--r-- | Utility/Tmp.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Utility/Tmp.hs b/Utility/Tmp.hs index 186cd12..891ce50 100644 --- a/Utility/Tmp.hs +++ b/Utility/Tmp.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Utility.Tmp where import Control.Exception (bracket) @@ -61,8 +63,17 @@ withTmpDir template a = do withTmpDirIn :: FilePath -> Template -> (FilePath -> IO a) -> IO a withTmpDirIn tmpdir template = bracket create remove where - remove d = whenM (doesDirectoryExist d) $ + remove d = whenM (doesDirectoryExist d) $ do +#if mingw32_HOST_OS + -- Windows will often refuse to delete a file + -- after a process has just written to it and exited. + -- Because it's crap, presumably. So, ignore failure + -- to delete the temp directory. + _ <- tryIO $ removeDirectoryRecursive d + return () +#else removeDirectoryRecursive d +#endif create = do createDirectoryIfMissing True tmpdir makenewdir (tmpdir </> template) (0 :: Int) |