Simplify upgrade copying logic

This commit is contained in:
Ben Gamari 2020-07-07 13:39:58 -04:00 committed by Julian Ospald
parent 62b628cb05
commit 16d4a28454
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -929,20 +929,12 @@ upgradeGHCup dls mtarget force = do
`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