Make sure directories exist

This commit is contained in:
2020-03-17 19:16:21 +01:00
parent 35b6359c1b
commit f8448cf02b
2 changed files with 8 additions and 10 deletions

View File

@@ -135,13 +135,10 @@ getDownloads urlSource = do
L.ByteString
smartDl uri' = do
let path = view pathL' uri'
json_file <- (liftIO $ ghcupCacheDir)
>>= \cacheDir -> (cacheDir </>) <$> urlBaseName path
cacheDir <- liftIO $ ghcupCacheDir
json_file <- (cacheDir </>) <$> urlBaseName path
e <-
liftIO
$ HIO.handleIOError
(\e -> if isDoesNotExistError e then pure False else throwIO e)
$ doesFileExist json_file
liftIO $ doesFileExist json_file
if e
then do
accessTime <-
@@ -168,6 +165,7 @@ getDownloads urlSource = do
else -- access in less than 5 minutes, re-use file
liftIO $ readFile json_file
else do
liftIO $ createDirIfMissing newDirPerms cacheDir
getModTime >>= \case
Just modTime -> do
bs <- liftE $ downloadBS uri'