Fix upgradeGHCup
File needs to be unlinked first, because it might potentially be in use.
This commit is contained in:
parent
df9dd0e785
commit
d2efb504b9
11
lib/GHCup.hs
11
lib/GHCup.hs
@ -690,17 +690,22 @@ upgradeGHCup dls mtarget = do
|
|||||||
lift $ $(logInfo) [i|Upgrading GHCup...|]
|
lift $ $(logInfo) [i|Upgrading GHCup...|]
|
||||||
let latestVer = fromJust $ getLatest dls GHCup
|
let latestVer = fromJust $ getLatest dls GHCup
|
||||||
pfreq <- liftE platformRequest
|
pfreq <- liftE platformRequest
|
||||||
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
|
dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls
|
||||||
tmp <- lift withGHCupTmpDir
|
tmp <- lift withGHCupTmpDir
|
||||||
let fn = [rel|ghcup|]
|
let fn = [rel|ghcup|]
|
||||||
p <- liftE $ download dli tmp (Just fn)
|
p <- liftE $ download dli tmp (Just fn)
|
||||||
case mtarget of
|
case mtarget of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
dest <- liftIO $ ghcupBinDir
|
dest <- liftIO $ ghcupBinDir
|
||||||
|
liftIO $ hideError NoSuchThing $ deleteFile (dest </> fn)
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile p
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile p
|
||||||
(dest </> fn)
|
(dest </> fn)
|
||||||
Overwrite
|
Overwrite
|
||||||
Just fullDest -> liftIO $ copyFile p fullDest Overwrite
|
Just fullDest -> do
|
||||||
|
liftIO $ hideError NoSuchThing $ deleteFile fullDest
|
||||||
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile p
|
||||||
|
fullDest
|
||||||
|
Overwrite
|
||||||
pure latestVer
|
pure latestVer
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user