Commit 80ce44f7 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Always pay attention to -keep-tmp-files when we want to delete files

parent 5b910663
......@@ -339,9 +339,8 @@ defaultErrorHandler dflags inner =
defaultCleanupHandler :: DynFlags -> IO a -> IO a
defaultCleanupHandler dflags inner =
-- make sure we clean up after ourselves
later (unless (dopt Opt_KeepTmpFiles dflags) $
do cleanTempFiles dflags
cleanTempDirs dflags
later (do cleanTempFiles dflags
cleanTempDirs dflags
)
-- exceptions will be blocked while we clean the temporary files,
-- so there shouldn't be any difficulty if we receive further
......
......@@ -494,22 +494,25 @@ GLOBAL_VAR(v_DirsToClean, emptyFM, FiniteMap FilePath FilePath )
\begin{code}
cleanTempDirs :: DynFlags -> IO ()
cleanTempDirs dflags
= do ds <- readIORef v_DirsToClean
= unless (dopt Opt_KeepTmpFiles dflags)
$ do ds <- readIORef v_DirsToClean
removeTmpDirs dflags (eltsFM ds)
writeIORef v_DirsToClean emptyFM
cleanTempFiles :: DynFlags -> IO ()
cleanTempFiles dflags
= do fs <- readIORef v_FilesToClean
removeTmpFiles dflags fs
writeIORef v_FilesToClean []
= unless (dopt Opt_KeepTmpFiles dflags)
$ do fs <- readIORef v_FilesToClean
removeTmpFiles dflags fs
writeIORef v_FilesToClean []
cleanTempFilesExcept :: DynFlags -> [FilePath] -> IO ()
cleanTempFilesExcept dflags dont_delete
= do files <- readIORef v_FilesToClean
let (to_keep, to_delete) = partition (`elem` dont_delete) files
removeTmpFiles dflags to_delete
writeIORef v_FilesToClean to_keep
= unless (dopt Opt_KeepTmpFiles dflags)
$ do files <- readIORef v_FilesToClean
let (to_keep, to_delete) = partition (`elem` dont_delete) files
removeTmpFiles dflags to_delete
writeIORef v_FilesToClean to_keep
-- find a temporary name that doesn't already exist.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment