Fix nuke bug on windows
This commit is contained in:
parent
043500e8e8
commit
77419ea41d
@ -73,6 +73,7 @@ import Prelude hiding ( abs
|
|||||||
import System.Environment
|
import System.Environment
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import System.IO.Error
|
import System.IO.Error
|
||||||
|
import System.IO.Temp
|
||||||
import Text.Regex.Posix
|
import Text.Regex.Posix
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
@ -133,6 +134,7 @@ rmTool :: ( MonadReader env m
|
|||||||
=> ListResult
|
=> ListResult
|
||||||
-> Excepts '[NotInstalled, UninstallFailed] m ()
|
-> Excepts '[NotInstalled, UninstallFailed] m ()
|
||||||
rmTool ListResult {lVer, lTool, lCross} = do
|
rmTool ListResult {lVer, lTool, lCross} = do
|
||||||
|
logInfo $ "removing " <> T.pack (show lTool) <> " version " <> prettyVer lVer
|
||||||
case lTool of
|
case lTool of
|
||||||
GHC ->
|
GHC ->
|
||||||
let ghcTargetVersion = GHCTargetVersion lCross lVer
|
let ghcTargetVersion = GHCTargetVersion lCross lVer
|
||||||
@ -364,11 +366,12 @@ rmGhcup = do
|
|||||||
if isWindows
|
if isWindows
|
||||||
then do
|
then do
|
||||||
-- since it doesn't seem possible to delete a running exe on windows
|
-- since it doesn't seem possible to delete a running exe on windows
|
||||||
-- we move it to temp dir, to be deleted at next reboot
|
-- we move it to system temp dir, to be deleted at next reboot
|
||||||
tempFilepath <- mkGhcupTmpDir
|
tmp <- liftIO $ getCanonicalTemporaryDirectory >>= \t -> createTempDirectory t "ghcup"
|
||||||
|
logDebug $ "mv " <> T.pack ghcupFilepath <> " " <> T.pack (tmp </> "ghcup")
|
||||||
hideError UnsupportedOperation $
|
hideError UnsupportedOperation $
|
||||||
liftIO $ hideError NoSuchThing $
|
liftIO $ hideError NoSuchThing $
|
||||||
moveFile ghcupFilepath (fromGHCupPath tempFilepath </> "ghcup")
|
moveFile ghcupFilepath (tmp </> "ghcup")
|
||||||
else
|
else
|
||||||
-- delete it.
|
-- delete it.
|
||||||
hideError doesNotExistErrorType $ rmFile ghcupFilepath
|
hideError doesNotExistErrorType $ rmFile ghcupFilepath
|
||||||
|
Loading…
Reference in New Issue
Block a user