Skip to content

Commit

Permalink
Merge pull request ocaml#4934 from dra27/multiple-caches-take-2
Browse files Browse the repository at this point in the history
Actually permit multiple state caches to co-exist
  • Loading branch information
AltGr authored and rjbou committed Apr 22, 2022
1 parent 17a0571 commit 373bf48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ New option/command/subcommand are prefixed with ◈.
*

## State
*
* Actually allow multiple state caches to co-exist [#4934 @dra27 - fix #4554 properly this time]

# Opam file format
*
Expand Down
17 changes: 11 additions & 6 deletions src/state/opamRepositoryState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ module Cache = struct
in
List.iter remove_cache_file (OpamFilename.files cache_dir)

let save rt =
let file = OpamPath.state_cache rt.repos_global.root in
let marshall rt =
(* Repository without remote are not cached, they are intended to be
manually edited *)
let filter_out_nourl repos_map =
Expand All @@ -49,17 +48,23 @@ module Cache = struct
with Not_found -> false)
repos_map
in
let t =
{ cached_repofiles =
OpamRepositoryName.Map.bindings
(filter_out_nourl rt.repos_definitions);
cached_opams =
OpamRepositoryName.Map.bindings
(filter_out_nourl rt.repo_opams);
}
in

let file rt =
OpamPath.state_cache rt.repos_global.root

let save rt =
remove ();
C.save file t
C.save (file rt) (marshall rt)

let save_new rt =
C.save (file rt) (marshall rt)

let load root =
let file = OpamPath.state_cache root in
Expand Down Expand Up @@ -231,7 +236,7 @@ let load lock_kind gt =
repos_map (OpamRepositoryName.Map.empty, OpamRepositoryName.Map.empty)
in
let rt = make_rt repofiles opams in
Cache.save rt;
Cache.save_new rt;
rt

let find_package_opt rt repo_list nv =
Expand Down

0 comments on commit 373bf48

Please sign in to comment.