Skip to content

Commit 14b3719

Browse files
committed
Add failure to directory creation
1 parent bf9c4d2 commit 14b3719

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
@@ -7,6 +7,7 @@
77
{-# LANGUAGE LambdaCase #-}
88
{-# LANGUAGE OverloadedStrings #-}
99
{-# LANGUAGE ScopedTypeVariables #-}
10+
{-# LANGUAGE NumericUnderscores #-}
1011

1112
{-# OPTIONS_GHC -Wno-orphans #-}
1213

@@ -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,8 +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-
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
257266

258267
createSubdirectoryIfMissingNew :: ()
259268
=> HasCallStack

0 commit comments

Comments
 (0)