Skip to content

Commit 83e2915

Browse files
Add validation that path to be deleted is in fact managed
Signed-off-by: Marek Kubica <[email protected]>
1 parent 79b9a25 commit 83e2915

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/dune_pkg/lock_dir.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,9 +1391,14 @@ module Write_disk = struct
13911391
| Ok `Non_existant -> Fun.const ()
13921392
| Ok `Is_existing_lock_dir ->
13931393
fun () ->
1394-
(* dev-tool lock dirs are external paths despite living in _build, they're
1395-
safe to remove *)
1396-
Path.rm_rf ~allow_external:true path
1394+
let path =
1395+
match path with
1396+
| In_source_tree _ | In_build_dir _ -> path
1397+
| External e ->
1398+
(* it might be a dev-tool path, try to convert *)
1399+
Workspace.dev_tool_path_to_source_dir e |> Path.source
1400+
in
1401+
Path.rm_rf path
13971402
| Error e -> raise_user_error_on_check_existance path e
13981403
;;
13991404

0 commit comments

Comments
 (0)