From 90791a60d200ed17429e352681971cb6da5f5510 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 23 Jun 2015 10:04:03 +0300 Subject: [PATCH] Remove uncompressed .tar file #376 --- ChangeLog.md | 4 ++++ src/Stack/Setup.hs | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 23460e408f..9a897d229d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +## Unreleased + +* Remove GHC uncompressed tar file after installation [#376](https://github.com/commercialhaskell/stack/issues/376) + ## 0.1.0.0 * Fall back to cabal dependency solver when a snapshot can't be found diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index d6aa0e2064..8c00e7ba8b 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -15,6 +15,7 @@ module Stack.Setup ) where import Control.Applicative +import Control.Exception.Enclosed (catchIO) import Control.Monad (liftM, when, join, void) import Control.Monad.Catch import Control.Monad.IO.Class (MonadIO, liftIO) @@ -54,7 +55,7 @@ import Stack.GhcPkg (getCabalPkgVer, getGlobalDB) import Stack.Solver (getGhcVersion) import Stack.Types import Stack.Types.StackT -import System.Directory (doesDirectoryExist, createDirectoryIfMissing) +import System.Directory (doesDirectoryExist, createDirectoryIfMissing, removeFile) import System.Exit (ExitCode (ExitSuccess)) import System.FilePath (searchPathSeparator) import qualified System.FilePath as FP @@ -580,6 +581,13 @@ installGHCWindows si archiveFile archiveType destDir _ = do run7z (parent archiveFile) archiveFile run7z (parent archiveFile) tarFile + liftIO (removeFile $ toFilePath tarFile) `catchIO` \e -> + $logWarn (T.concat + [ "Exception when removing " + , T.pack $ toFilePath tarFile + , ": " + , T.pack $ show e + ]) $logInfo $ "GHC installed to " <> T.pack (toFilePath destDir)