From 2be1aa2707d1cd303c4d807b374b3df474fb0eb6 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 7 Jul 2020 13:39:58 -0400 Subject: [PATCH] Simplify upgrade copying logic --- app/ghcup/BrickMain.hs | 8 +++++--- lib/GHCup.hs | 21 ++++++--------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs index 2b3c272..853896c 100644 --- a/app/ghcup/BrickMain.hs +++ b/app/ghcup/BrickMain.hs @@ -71,9 +71,11 @@ ui AppState {..} = ) ) <=> ( withAttr "help" - $ foldr1 (\x y -> x <+> str " " <+> y) - . (++ [str "↑↓:Navigation"]) - $ (fmap (\(c, s, _) -> str (c : ':' : s)) keyHandlers) + . txtWrap + . T.pack + . foldr1 (\x y -> x <> " " <> y) + . (++ ["↑↓:Navigation"]) + $ (fmap (\(c, s, _) -> (c : ':' : s)) keyHandlers) ) where diff --git a/lib/GHCup.hs b/lib/GHCup.hs index c9adfd0..5abdd5b 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -928,21 +928,12 @@ upgradeGHCup dls mtarget force = do `unionFileModes` groupExecuteMode `unionFileModes` otherExecuteMode binDir <- liftIO $ ghcupBinDir - liftIO $ createDirIfMissing newDirPerms binDir - case mtarget of - Nothing -> do - dest <- liftIO $ ghcupBinDir - liftIO $ hideError NoSuchThing $ deleteFile (dest fn) - handleIO (throwE . CopyError . show) $ liftIO $ copyFile p - (dest fn) - Overwrite - liftIO $ setFileMode (toFilePath (dest fn)) fileMode' - Just fullDest -> do - liftIO $ hideError NoSuchThing $ deleteFile fullDest - handleIO (throwE . CopyError . show) $ liftIO $ copyFile p - fullDest - Overwrite - liftIO $ setFileMode (toFilePath fullDest) fileMode' + let fullDest = fromMaybe (binDir fn) mtarget + liftIO $ hideError NoSuchThing $ deleteFile fullDest + handleIO (throwE . CopyError . show) $ liftIO $ copyFile p + fullDest + Overwrite + liftIO $ setFileMode (toFilePath fullDest) fileMode' pure latestVer