@@ -22,24 +22,21 @@ let rec build_path_to_root ~(frontier : Transition_frontier.t) ~current_hash
2222
2323let check_directories_exist ~logger ~persistent_root_location
2424 ~persistent_frontier_location =
25- let % bind root_exists =
26- Sys. file_exists persistent_root_location
27- >> | function `Yes -> true | `No | `Unknown -> false
28- in
29- let % bind frontier_exists =
30- Sys. file_exists persistent_frontier_location
31- >> | function `Yes -> true | `No | `Unknown -> false
32- in
33- if not root_exists then (
34- [% log' error logger] " Persistent root directory not found at $location"
35- ~metadata: [ (" location" , `String persistent_root_location) ] ;
36- Deferred. return (Error " Persistent root not found - nothing to fix against" )
37- )
38- else if not frontier_exists then (
39- [% log' info logger]
40- " Persistent frontier directory not found - nothing to fix" ;
41- Deferred. return (Ok `No_frontier ) )
42- else Deferred. return (Ok `Both_exist )
25+ match % map
26+ Deferred. both
27+ (Sys. file_exists persistent_root_location)
28+ (Sys. file_exists persistent_frontier_location)
29+ with
30+ | (`No | `Unknown ), _ ->
31+ [% log' error logger] " Persistent root directory not found at $location"
32+ ~metadata: [ (" location" , `String persistent_root_location) ] ;
33+ Error " Persistent root not found - nothing to fix against"
34+ | _ , (`No | `Unknown ) ->
35+ [% log' info logger]
36+ " Persistent frontier directory not found - nothing to fix" ;
37+ Ok `No_frontier
38+ | _ ->
39+ Ok `Both_exist
4340
4441(* Apply a sequence of root transition diffs to the persistent database *)
4542let apply_root_transitions ~logger ~db diffs =
0 commit comments