Summary: First real step to keep an inventory of all the entries in infer-out/ in a single place, and associate meta-data to each entry. In particular, we want to avoid adding things in infer-out/ without a clear idea of whether they should be cleaned up before going into a cache, or before an incremental analysis. Migrate infer-out/tmp/ first just as an example and an excuse to write the scaffolding code needed for all the other entries. Reviewed By: skcho Differential Revision: D20894300 fbshipit-source-id: f796fca55master
parent
93bce54085
commit
b122eaef59
@ -0,0 +1,49 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
open! IStd
|
||||
|
||||
type id = Temporary [@@deriving enumerate]
|
||||
|
||||
type cleanup_action = Delete | Keep [@@deriving equal]
|
||||
|
||||
type entry_kind = Directory
|
||||
|
||||
type t =
|
||||
{ rel_path: string (** path inside infer-out/ *)
|
||||
; kind: entry_kind
|
||||
; before_incremental_analysis: cleanup_action
|
||||
(** whether this should be deleted before an incremental analysis *)
|
||||
; before_caching_capture: cleanup_action
|
||||
(** whether this should be deleted before sending to a remote cache for the capture phase,
|
||||
e.g., a distributed Buck cache. *) }
|
||||
|
||||
let of_id = function
|
||||
| Temporary ->
|
||||
{ rel_path= "tmp"
|
||||
; kind= Directory
|
||||
; before_incremental_analysis= Keep
|
||||
; before_caching_capture= Delete }
|
||||
|
||||
|
||||
let path_of_entry ~results_dir {rel_path; _} = results_dir ^/ rel_path
|
||||
|
||||
let get_path ~results_dir id = path_of_entry ~results_dir (of_id id)
|
||||
|
||||
let get_filtered_paths ~results_dir ~f =
|
||||
List.filter_map all_of_id ~f:(fun id ->
|
||||
let entry = of_id id in
|
||||
if f entry then Some (path_of_entry ~results_dir entry) else None )
|
||||
|
||||
|
||||
let to_delete_before_incremental_capture_and_analysis ~results_dir =
|
||||
get_filtered_paths ~results_dir ~f:(fun {before_incremental_analysis; _} ->
|
||||
equal_cleanup_action before_incremental_analysis Delete )
|
||||
|
||||
|
||||
let to_delete_before_caching_capture ~results_dir =
|
||||
get_filtered_paths ~results_dir ~f:(fun {before_caching_capture; _} ->
|
||||
equal_cleanup_action before_caching_capture Delete )
|
@ -0,0 +1,21 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
open! IStd
|
||||
|
||||
(** Entries in the results directory (infer-out/). Unless you want to specify a custom results
|
||||
directory you probably want to use {!ResultsDir.Entry} instead of this module. *)
|
||||
|
||||
type id = Temporary (** directory containing temp files *)
|
||||
|
||||
val get_path : results_dir:string -> id -> string
|
||||
(** the absolute path for the given entry *)
|
||||
|
||||
val to_delete_before_incremental_capture_and_analysis : results_dir:string -> string list
|
||||
(** utility for {!ResultsDir.scrub_for_incremental}, you probably want to use that instead *)
|
||||
|
||||
val to_delete_before_caching_capture : results_dir:string -> string list
|
||||
(** utility for {!ResultsDir.scrub_for_caching}, you probably want to use that instead *)
|
Loading…
Reference in new issue