implements checking if file already exists for Cabal installs
This commit is contained in:
parent
ce6fb0bb1e
commit
c2c5625685
@ -442,6 +442,7 @@ install' _ (_, ListResult {..}) = do
|
||||
, DownloadFailed
|
||||
, NoUpdate
|
||||
, TarDirDoesNotExist
|
||||
, FileAlreadyExistsError
|
||||
]
|
||||
|
||||
run (do
|
||||
|
@ -1478,6 +1478,7 @@ Report bugs at <https://gitlab.haskell.org/haskell/ghcup-hs/issues>|]
|
||||
, TarDirDoesNotExist
|
||||
, NextVerNotFound
|
||||
, NoToolVersionSet
|
||||
, FileAlreadyExistsError
|
||||
]
|
||||
|
||||
let runInstTool mInstPlatform action' = do
|
||||
|
@ -405,6 +405,7 @@ installCabalBindist :: ( MonadMask m
|
||||
#if !defined(TAR)
|
||||
, ArchiveResult
|
||||
#endif
|
||||
, FileAlreadyExistsError
|
||||
]
|
||||
m
|
||||
()
|
||||
@ -456,13 +457,16 @@ installCabalUnpacked :: (MonadLogger m, MonadCatch m, MonadIO m)
|
||||
=> FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides)
|
||||
-> FilePath -- ^ Path to install to
|
||||
-> Version
|
||||
-> Excepts '[CopyError] m ()
|
||||
-> Excepts '[CopyError, FileAlreadyExistsError] m ()
|
||||
installCabalUnpacked path inst ver = do
|
||||
lift $ $(logInfo) "Installing cabal"
|
||||
let cabalFile = "cabal"
|
||||
liftIO $ createDirRecursive' inst
|
||||
let destFileName = cabalFile <> "-" <> T.unpack (prettyVer ver) <> exeExt
|
||||
let destPath = inst </> destFileName
|
||||
whenM
|
||||
(liftIO $ doesFileExist destPath)
|
||||
(throwE $ FileAlreadyExistsError destPath)
|
||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||
(path </> cabalFile <> exeExt)
|
||||
destPath
|
||||
@ -498,6 +502,7 @@ installCabalBin :: ( MonadMask m
|
||||
#if !defined(TAR)
|
||||
, ArchiveResult
|
||||
#endif
|
||||
, FileAlreadyExistsError
|
||||
]
|
||||
m
|
||||
()
|
||||
|
Loading…
Reference in New Issue
Block a user