Skip to content
Snippets Groups Projects
Commit 226a7c21 authored by Michele Alberti's avatar Michele Alberti
Browse files

[kernel] Avoid to create an already existing directory. Abort if a file with...

[kernel] Avoid to create an already existing directory. Abort if a file with same path already exists.
parent e74ac27b
No related branches found
No related tags found
No related merge requests found
...@@ -395,8 +395,19 @@ struct ...@@ -395,8 +395,19 @@ struct
| `Normalize_only -> | `Normalize_only ->
filepath filepath
| `Create_path -> | `Create_path ->
ignore (mk_dir (filepath :> string)); begin
filepath (try
if not (Sys.is_directory (filepath :> string))
then
(* [filepath] already exists, and it is a file. *)
L.abort
"cannot create directory as file %a already exists"
Datatype.Filepath.pretty filepath
with Sys_error _ ->
(* [filepath] does not exist: create the directory path. *)
ignore (mk_dir (filepath :> string)));
filepath
end
end end
let get_file ?(mode=`Normalize_only) s = let get_file ?(mode=`Normalize_only) s =
...@@ -448,7 +459,9 @@ struct ...@@ -448,7 +459,9 @@ struct
end) end)
let () = let () =
if is_kernel () if is_kernel ()
then Journal.get_session_file := (fun s -> Session.get_file s) then
Journal.get_session_file :=
(fun s -> Session.get_file ~mode:`Create_path s)
module Config = module Config =
Make_specific_dir Make_specific_dir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment