From d2efb504b937738ecf3df27c835001f4e6e17d19 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 12 Apr 2020 18:54:03 +0200 Subject: [PATCH] Fix upgradeGHCup File needs to be unlinked first, because it might potentially be in use. --- lib/GHCup.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 7ed8075..dde8072 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -690,17 +690,22 @@ upgradeGHCup dls mtarget = do lift $ $(logInfo) [i|Upgrading GHCup...|] let latestVer = fromJust $ getLatest dls GHCup pfreq <- liftE platformRequest - dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls - tmp <- lift withGHCupTmpDir + dli <- lE $ getDownloadInfo GHCup latestVer pfreq dls + tmp <- lift withGHCupTmpDir let fn = [rel|ghcup|] p <- liftE $ download dli tmp (Just fn) case mtarget of Nothing -> do dest <- liftIO $ ghcupBinDir + liftIO $ hideError NoSuchThing $ deleteFile (dest fn) handleIO (throwE . CopyError . show) $ liftIO $ copyFile p (dest fn) 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