From 0c666a6bbeebcd5d86b2dbaa32b5d9d7a6907800 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 27 Jul 2021 20:57:51 +0200 Subject: [PATCH] Fix upgrade subcommand running appstate twice --- app/ghcup/Main.hs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index a527255..15ac4f0 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -2026,22 +2026,25 @@ Make sure to clean up #{tmpdir} afterwards.|]) (UpgradeAt p) -> pure $ Just p UpgradeGHCupDir -> pure (Just (binDir "ghcup" <> exeExt)) - runUpgrade (liftE $ upgradeGHCup target force') >>= \case - VRight v' -> do - GHCupInfo { _ghcupDownloads = dls } <- runAppState getGHCupInfo - let pretty_v = prettyVer v' - let vi = fromJust $ snd <$> getLatest dls GHCup - runLogger $ $(logInfo) - [i|Successfully upgraded GHCup to version #{pretty_v}|] - forM_ (_viPostInstall vi) $ \msg -> - runLogger $ $(logInfo) msg - pure ExitSuccess - VLeft (V NoUpdate) -> do - runLogger $ $(logWarn) [i|No GHCup update available|] - pure ExitSuccess - VLeft e -> do - runLogger $ $(logError) $ T.pack $ prettyShow e - pure $ ExitFailure 11 + runUpgrade (do + v' <- liftE $ upgradeGHCup target force' + GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo + pure (v', dls) + ) >>= \case + VRight (v', dls) -> do + let pretty_v = prettyVer v' + let vi = fromJust $ snd <$> getLatest dls GHCup + runLogger $ $(logInfo) + [i|Successfully upgraded GHCup to version #{pretty_v}|] + forM_ (_viPostInstall vi) $ \msg -> + runLogger $ $(logInfo) msg + pure ExitSuccess + VLeft (V NoUpdate) -> do + runLogger $ $(logWarn) [i|No GHCup update available|] + pure ExitSuccess + VLeft e -> do + runLogger $ $(logError) $ T.pack $ prettyShow e + pure $ ExitFailure 11 ToolRequirements -> do s' <- appState