Merge branch 'isolateDir'

This commit is contained in:
2022-05-11 20:35:38 +02:00
10 changed files with 195 additions and 158 deletions

View File

@@ -628,3 +628,16 @@ data CapturedProcess = CapturedProcess
deriving (Eq, Show)
makeLenses ''CapturedProcess
data InstallDir = IsolateDir FilePath
| GHCupInternal
deriving (Eq, Show)
data InstallDirResolved = IsolateDirResolved FilePath
| GHCupDir FilePath
deriving (Eq, Show)
fromInstallDir :: InstallDirResolved -> FilePath
fromInstallDir (IsolateDirResolved fp) = fp
fromInstallDir (GHCupDir fp) = fp

View File

@@ -1265,9 +1265,10 @@ ghcBinaryName (GHCTargetVersion Nothing _) = T.unpack ("ghc" <> T.pack exeExt)
installDestSanityCheck :: ( MonadIO m
, MonadCatch m
) =>
FilePath ->
InstallDirResolved ->
Excepts '[DirNotEmpty] m ()
installDestSanityCheck isoDir = do
installDestSanityCheck (IsolateDirResolved isoDir) = do
hideErrorDef [doesNotExistErrorType] () $ do
contents <- liftIO $ getDirectoryContentsRecursive isoDir
unless (null contents) (throwE $ DirNotEmpty isoDir)
installDestSanityCheck _ = pure ()