update `installHLSBindist` to take a "Maybe FilePath" argument for isolated installs

This commit is contained in:
Arjun Kathuria 2021-07-25 22:08:32 +05:30
parent 781cf8eed5
commit 7471f4f4dc
1 changed files with 19 additions and 7 deletions

View File

@ -530,6 +530,7 @@ installHLSBindist :: ( MonadMask m
)
=> DownloadInfo
-> Version
-> Maybe FilePath -- ^ isolated install path, if user passed any
-> Excepts
'[ AlreadyInstalled
, CopyError
@ -545,12 +546,16 @@ installHLSBindist :: ( MonadMask m
]
m
()
installHLSBindist dlinfo ver = do
installHLSBindist dlinfo ver isoFilepath = do
lift $ $(logDebug) [i|Requested to install hls version #{ver}|]
PlatformRequest {..} <- lift getPlatformReq
Dirs {..} <- lift getDirs
let isIsolatedInstall = isJust isoFilepath
-- we only check for already installed in regular (non-isolated) installs
when (not isIsolatedInstall) $
whenM (lift (hlsInstalled ver))
(throwE $ AlreadyInstalled HLS ver)
@ -564,10 +569,17 @@ installHLSBindist dlinfo ver = do
-- the subdir of the archive where we do the work
workdir <- maybe (pure tmpUnpack) (liftE . intoSubdir tmpUnpack) (view dlSubdir dlinfo)
let isoDir = fromJust isoFilepath
if isIsolatedInstall
then do
lift $ $(logInfo) [i|isolated installing HLS to #{isoDir}|]
liftE $ installHLS' workdir isoDir ver
else do
liftE $ installHLS' workdir binDir ver
-- create symlink if this is the latest version
-- create symlink if this is the latest version in a regular install
whenM (pure $ not isIsolatedInstall) $ do
hlsVers <- lift $ fmap rights getInstalledHLSs
let lInstHLS = headMay . reverse . sort $ hlsVers
when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver