Skip to content

Commit 87ee902

Browse files
committed
fix: Fix a small race condition in builder
1 parent 2792faf commit 87ee902

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/utils/lwt_utils.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
open Lwt.Infix
1010

1111
let rec mkdir_p ?(perm=0o755) dir =
12-
Lwt_unix.file_exists dir >>= function
13-
| true ->
12+
if Sys.file_exists dir then
1413
if Sys.is_directory dir then
1514
Lwt.return ()
1615
else
1716
Lwt.fail_with
1817
(Printf.sprintf "Can't create dir: file %s is in the way" dir)
19-
| false ->
20-
mkdir_p (Filename.dirname dir) >>= fun () ->
21-
Lwt_unix.mkdir dir perm
18+
else
19+
if Sys.file_exists (Filename.dirname dir) then
20+
Lwt.return (Unix.mkdir dir perm)
21+
else
22+
mkdir_p ~perm (Filename.dirname dir) >>= fun () ->
23+
mkdir_p ~perm dir
2224

2325
let copy_file src dst =
2426
Lwt.catch (fun () ->

0 commit comments

Comments
 (0)