diff --git a/src/build_system.ml b/src/build_system.ml index 80c8f56f..6950811d 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -10,6 +10,11 @@ let alias_dir = Path.(relative build_dir) ".aliases" let misc_dir = Path.(relative build_dir) ".misc" module Promoted_to_delete = struct + module P = Utils.Persistent(struct + type t = Path.t list + let name = "PROMOTED-TO-DELETE" + let version = 1 + end) let db = ref [] let fn = Path.relative Path.build_dir ".to-delete-in-source-tree" @@ -17,19 +22,15 @@ module Promoted_to_delete = struct let add p = db := p :: !db let load () = - if Path.exists fn then - Io.Sexp.load fn ~mode:Many - |> List.map ~f:(Sexp.Of_sexp.parse Path.t Univ_map.empty) - else - [] + Option.value ~default:[] (P.load fn) let dump () = - let db = Path.Set.union (Path.Set.of_list !db) (Path.Set.of_list (load ())) in if Path.build_dir_exists () then - Io.write_file fn - (String.concat ~sep:"" - (List.map (Path.Set.to_list db) ~f:(fun p -> - Sexp.to_string ~syntax:Dune (Path.sexp_of_t p) ^ "\n"))) + load () + |> Path.Set.of_list + |> Path.Set.union (Path.Set.of_list !db) + |> Path.Set.to_list + |> P.dump fn end let files_in_source_tree_to_delete () =