Skip to content

Commit

Permalink
Show the progress of the file tree scanning
Browse files Browse the repository at this point in the history
Signed-off-by: François Bobot <francois.bobot@cea.fr>
  • Loading branch information
bobot committed Jul 26, 2019
1 parent f03f703 commit 5a72065
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/file_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,12 @@ let readdir path =

let load ?(warn_when_seeing_jbuild_file=true) path ~ancestor_vcs =
let open Result.O in
let nb_path_visited = ref 0 in
let rec walk path ~dirs_visited ~project:parent_project ~vcs ~(dir_status : Sub_dirs.Status.t)
: (_, _) Result.t =
incr nb_path_visited;
if !nb_path_visited mod 100 = 0 then
Console.update_status_line (Pp.verbatim (Printf.sprintf "scanned %i directories" !nb_path_visited));
let+ { dirs; files } = readdir path in
let project =
if dir_status = Data_only then
Expand Down Expand Up @@ -347,15 +351,19 @@ let load ?(warn_when_seeing_jbuild_file=true) path ~ancestor_vcs =
in
Dir.create ~path ~contents ~status:dir_status ~project ~vcs
in
let clean () = Console.clear_status_line () in
match
walk path
~dirs_visited:(File.Map.singleton (File.of_source_path path) path)
~dir_status:Normal
~project:(Lazy.force Dune_project.anonymous)
~vcs:ancestor_vcs
with
| Ok dir -> dir
| Ok dir ->
clean ();
dir
| Error m ->
clean ();
User_error.raise [ Pp.textf "Unable to load source %s.@.Reason:%s@."
(Path.Source.to_string_maybe_quoted path) (Unix.error_message m) ]

Expand Down

0 comments on commit 5a72065

Please sign in to comment.