Skip to content

Commit

Permalink
fix Fpath.rm_rf error message
Browse files Browse the repository at this point in the history
Signed-off-by: EduardoRFS <theeduardorfs@gmail.com>
  • Loading branch information
EduardoRFS authored and rgrinberg committed Mar 18, 2022
1 parent 8677fe3 commit 9b8c6cb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

- Show auto-detected concurrency on Windows too (#5502, @MisterDA)

- Fix operations that remove folders with absolute path. This happens when using esy (#5507, @EduardoRFS)

3.0.3 (Unreleased)
------------------

Expand Down
4 changes: 1 addition & 3 deletions otherlibs/stdune/fpath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ and rm_rf_dir path =
deleted the directory. *)
())

let rm_rf ?(allow_external = false) fn =
if (not allow_external) && not (Filename.is_relative fn) then
Code_error.raise "Path.rm_rf called on external dir" [ ("fn", String fn) ];
let rm_rf fn =
match Unix.lstat fn with
| exception Unix.Unix_error (ENOENT, _, _) -> ()
| { Unix.st_kind = S_DIR; _ } -> rm_rf_dir fn
Expand Down
2 changes: 1 addition & 1 deletion otherlibs/stdune/fpath.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ type clear_dir_result =
val clear_dir : string -> clear_dir_result

(** If the path does not exist, this function is a no-op. *)
val rm_rf : ?allow_external:bool -> string -> unit
val rm_rf : string -> unit

val is_root : string -> bool
2 changes: 1 addition & 1 deletion otherlibs/stdune/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ let clear_dir dir = Fpath.clear_dir (to_string dir)
let rm_rf ?(allow_external = false) t =
if (not allow_external) && not (is_managed t) then
Code_error.raise "Path.rm_rf called on external dir" [ ("t", to_dyn t) ];
Fpath.rm_rf ~allow_external (to_string t)
Fpath.rm_rf (to_string t)

let mkdir_p ?perms = function
| External s -> External.mkdir_p s ?perms
Expand Down

0 comments on commit 9b8c6cb

Please sign in to comment.