Adds conditional windows ghcup bin removal code. Todo: test it, add
more exception handling if required.
This commit is contained in:
parent
d26ddf7015
commit
9f5df9db10
16
lib/GHCup.hs
16
lib/GHCup.hs
@ -1284,14 +1284,24 @@ rmStackVer ver = do
|
|||||||
|
|
||||||
-- assuming the current scheme of having just 1 ghcup bin, no version info is required.
|
-- assuming the current scheme of having just 1 ghcup bin, no version info is required.
|
||||||
rmGhcup :: ( MonadReader AppState m
|
rmGhcup :: ( MonadReader AppState m
|
||||||
, MonadIO m
|
, MonadIO m,
|
||||||
|
MonadCatch m
|
||||||
)
|
)
|
||||||
=> Excepts '[NotInstalled] m ()
|
=> Excepts '[NotInstalled] m ()
|
||||||
|
|
||||||
rmGhcup = do
|
rmGhcup = do
|
||||||
AppState {dirs = Dirs {binDir}} <- lift ask
|
AppState {dirs = Dirs {binDir}} <- lift ask
|
||||||
let ghcupFile = "ghcup" <> exeExt
|
let ghcupFilename = "ghcup" <> exeExt
|
||||||
liftIO $ hideError doesNotExistErrorType $ rmFile (binDir </> ghcupFile)
|
let ghcupFilepath = binDir </> ghcupFilename
|
||||||
|
#if defined(IS_WINDOWS)
|
||||||
|
-- since it doesn't seem possible to delete a running exec in windows
|
||||||
|
-- we move it to temp dir, to be deleted at next reboot
|
||||||
|
tempDir <- liftIO $ getTemporaryDirectory
|
||||||
|
tempFilepath = tempDir </> ghcupFilename
|
||||||
|
hideError doesNotExistErrorType $ liftIO $ renameFile ghcupFilepath tempFilepath
|
||||||
|
#else
|
||||||
|
hideError doesNotExistErrorType $ liftIO $ rmFile ghcupFilepath
|
||||||
|
#endif
|
||||||
|
|
||||||
rmTool :: ( MonadReader AppState m
|
rmTool :: ( MonadReader AppState m
|
||||||
, MonadLogger m
|
, MonadLogger m
|
||||||
|
Loading…
Reference in New Issue
Block a user