Skip to content

Commit db02709

Browse files
committed
Remove the build directory as soon as possible when installing a package
1 parent 3653413 commit db02709

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

master_changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ users)
2626
## Actions
2727

2828
## Install
29+
* Remove the build directory as soon as possible when installing a package [#6906 @kit-ty-kate - fix #5884]
2930

3031
## Build (package)
3132

src/client/opamSolution.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,14 @@ let parallel_apply t
683683
| Left conf ->
684684
add_to_install nv conf;
685685
store_time ();
686+
if not OpamClientConfig.(!r.keep_build_dir) then begin
687+
(* NOTE: build_dir as defined above is the
688+
"build dir in case of --inplace" so != OpamPath.Switch.build *)
689+
let build_dir =
690+
OpamPath.Switch.build t.switch_global.root t.switch nv
691+
in
692+
OpamFilename.rmdir build_dir;
693+
end;
686694
Done (`Successful (OpamPackage.Set.add nv installed, removed))
687695
| Right exn ->
688696
store_time ();
@@ -864,17 +872,13 @@ let parallel_apply t
864872
end;
865873

866874
let cleanup_artefacts graph =
875+
(* NOTE: build dir removal is done directly after install
876+
instead of here, for performance reasons. *)
867877
PackageActionGraph.iter_vertex (function
868878
| `Remove nv ->
869879
OpamAction.cleanup_package_artefacts t nv
870880
(* if reinstalled, only removes build dir *)
871-
| `Install nv ->
872-
if not OpamClientConfig.(!r.keep_build_dir) then
873-
let build_dir =
874-
OpamPath.Switch.build t.switch_global.root t.switch nv
875-
in
876-
OpamFilename.rmdir build_dir
877-
| `Build _ | `Fetch _ -> ()
881+
| `Build _ | `Fetch _ | `Install _ -> ()
878882
| `Change _ | `Reinstall _ -> assert false)
879883
graph
880884
in

0 commit comments

Comments
 (0)