Skip to content

Commit

Permalink
fix: Fix a small race condition in builder
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed Nov 3, 2023
1 parent 2792faf commit 87ee902
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils/lwt_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
open Lwt.Infix

let rec mkdir_p ?(perm=0o755) dir =
Lwt_unix.file_exists dir >>= function
| true ->
if Sys.file_exists dir then
if Sys.is_directory dir then
Lwt.return ()
else
Lwt.fail_with
(Printf.sprintf "Can't create dir: file %s is in the way" dir)
| false ->
mkdir_p (Filename.dirname dir) >>= fun () ->
Lwt_unix.mkdir dir perm
else
if Sys.file_exists (Filename.dirname dir) then
Lwt.return (Unix.mkdir dir perm)
else
mkdir_p ~perm (Filename.dirname dir) >>= fun () ->
mkdir_p ~perm dir

let copy_file src dst =
Lwt.catch (fun () ->
Expand Down

0 comments on commit 87ee902

Please sign in to comment.