Ensure directories

This commit is contained in:
2021-06-13 13:41:06 +02:00
parent ef0c94fddd
commit b56c44a210
5 changed files with 21 additions and 10 deletions

View File

@@ -227,7 +227,6 @@ getBase dirs@Dirs{..} Settings{ downloader } =
else -- access in less than 5 minutes, re-use file
liftIO $ L.readFile json_file
else do
liftIO $ createDirRecursive' cacheDir
getModTime >>= \case
Just modTime -> dlWithMod modTime json_file
Nothing -> do

View File

@@ -1075,3 +1075,21 @@ ensureGlobalTools = do
#else
pure ()
#endif
-- | Ensure ghcup directory structure exists.
ensureDirectories :: Dirs -> IO ()
ensureDirectories dirs = do
let Dirs
{ baseDir
, binDir
, cacheDir
, logsDir
, confDir
} = dirs
createDirRecursive' baseDir
createDirRecursive' binDir
createDirRecursive' cacheDir
createDirRecursive' logsDir
createDirRecursive' confDir
pure ()

View File

@@ -22,7 +22,6 @@ import Control.Monad.IO.Class
import Control.Monad.Logger
import Prelude hiding ( appendFile )
import System.Console.Pretty
import System.Directory hiding ( findFiles )
import System.FilePath
import System.IO.Error
import Text.Regex.Posix
@@ -70,7 +69,6 @@ initGHCupFileLogging :: (MonadIO m) => FilePath -> m FilePath
initGHCupFileLogging logsDir = do
let logfile = logsDir </> "ghcup.log"
liftIO $ do
createDirectoryIfMissing True logsDir
logFiles <- findFiles
logsDir
(makeRegexOpts compExtended