Make sure directories exist
This commit is contained in:
parent
35b6359c1b
commit
f8448cf02b
@ -493,6 +493,10 @@ main = do
|
|||||||
>>= \opt@Options {..} -> do
|
>>= \opt@Options {..} -> do
|
||||||
let settings = toSettings opt
|
let settings = toSettings opt
|
||||||
|
|
||||||
|
-- create ~/.ghcup dir
|
||||||
|
ghcdir <- ghcupBaseDir
|
||||||
|
createDirIfMissing newDirPerms ghcdir
|
||||||
|
|
||||||
-- logger interpreter
|
-- logger interpreter
|
||||||
logfile <- initGHCupFileLogging [rel|ghcup.log|]
|
logfile <- initGHCupFileLogging [rel|ghcup.log|]
|
||||||
let runLogger = myLoggerT LoggerConfig
|
let runLogger = myLoggerT LoggerConfig
|
||||||
@ -588,10 +592,6 @@ main = do
|
|||||||
, DownloadFailed
|
, DownloadFailed
|
||||||
]
|
]
|
||||||
|
|
||||||
-- create ~/.ghcup dir
|
|
||||||
ghcdir <- ghcupBaseDir
|
|
||||||
createDirIfMissing newDirPerms ghcdir
|
|
||||||
|
|
||||||
dls <-
|
dls <-
|
||||||
( runLogger
|
( runLogger
|
||||||
. flip runReaderT settings
|
. flip runReaderT settings
|
||||||
|
@ -135,13 +135,10 @@ getDownloads urlSource = do
|
|||||||
L.ByteString
|
L.ByteString
|
||||||
smartDl uri' = do
|
smartDl uri' = do
|
||||||
let path = view pathL' uri'
|
let path = view pathL' uri'
|
||||||
json_file <- (liftIO $ ghcupCacheDir)
|
cacheDir <- liftIO $ ghcupCacheDir
|
||||||
>>= \cacheDir -> (cacheDir </>) <$> urlBaseName path
|
json_file <- (cacheDir </>) <$> urlBaseName path
|
||||||
e <-
|
e <-
|
||||||
liftIO
|
liftIO $ doesFileExist json_file
|
||||||
$ HIO.handleIOError
|
|
||||||
(\e -> if isDoesNotExistError e then pure False else throwIO e)
|
|
||||||
$ doesFileExist json_file
|
|
||||||
if e
|
if e
|
||||||
then do
|
then do
|
||||||
accessTime <-
|
accessTime <-
|
||||||
@ -168,6 +165,7 @@ getDownloads urlSource = do
|
|||||||
else -- access in less than 5 minutes, re-use file
|
else -- access in less than 5 minutes, re-use file
|
||||||
liftIO $ readFile json_file
|
liftIO $ readFile json_file
|
||||||
else do
|
else do
|
||||||
|
liftIO $ createDirIfMissing newDirPerms cacheDir
|
||||||
getModTime >>= \case
|
getModTime >>= \case
|
||||||
Just modTime -> do
|
Just modTime -> do
|
||||||
bs <- liftE $ downloadBS uri'
|
bs <- liftE $ downloadBS uri'
|
||||||
|
Loading…
Reference in New Issue
Block a user