Skip to content

Commit 25825b0

Browse files
committed
Update createDirectoryIfMissingNew
1 parent 8f27471 commit 25825b0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cardano-testnet/src/Testnet/Runtime.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE FlexibleInstances #-}
66
{-# LANGUAGE GADTs #-}
77
{-# LANGUAGE LambdaCase #-}
8+
{-# LANGUAGE NumericUnderscores #-}
89
{-# LANGUAGE OverloadedStrings #-}
910
{-# LANGUAGE ScopedTypeVariables #-}
1011

@@ -43,7 +44,7 @@ import GHC.Stack
4344
import qualified GHC.Stack as GHC
4445
import Network.Socket (HostAddress, PortNumber)
4546
import Prettyprinter (unAnnotate)
46-
import RIO (runRIO)
47+
import RIO (runRIO, threadDelay)
4748
import qualified System.Directory as IO
4849
import System.FilePath
4950
import qualified System.IO as IO
@@ -252,7 +253,16 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do
252253
createDirectoryIfMissingNew :: HasCallStack => FilePath -> IO FilePath
253254
createDirectoryIfMissingNew directory = GHC.withFrozenCallStack $ do
254255
IO.createDirectoryIfMissing True directory
255-
pure directory
256+
exists <- IO.doesDirectoryExist directory
257+
if exists
258+
then pure directory
259+
else do
260+
threadDelay 5_000_000
261+
IO.createDirectoryIfMissing True directory
262+
exists' <- IO.doesDirectoryExist directory
263+
if exists'
264+
then pure directory
265+
else throwString $ "Failed to create directory: " <> directory
256266

257267

258268
createSubdirectoryIfMissingNew :: ()

0 commit comments

Comments
 (0)