Skip to content

Commit eeedd74

Browse files
committed
Modify createDirectoryIfMissingNew
1 parent 3761ce8 commit eeedd74

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cardano-testnet/src/Testnet/Runtime.hs

Lines changed: 12 additions & 3 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
@@ -251,8 +252,16 @@ startNode tp node ipv4 port _testnetMagic nodeCmd = GHC.withFrozenCallStack $ do
251252

252253
createDirectoryIfMissingNew :: HasCallStack => FilePath -> IO FilePath
253254
createDirectoryIfMissingNew directory = GHC.withFrozenCallStack $ do
254-
IO.createDirectoryIfMissing True directory
255-
pure directory
255+
exists <- IO.doesDirectoryExist directory
256+
if exists
257+
then pure directory
258+
else do
259+
threadDelay 5_000_000
260+
IO.createDirectoryIfMissing True directory
261+
exists' <- IO.doesDirectoryExist directory
262+
if exists'
263+
then pure directory
264+
else throwString $ "Failed to create directory: " <> directory
256265

257266

258267
createSubdirectoryIfMissingNew :: ()

0 commit comments

Comments
 (0)