From 5a72065542857f60ef0bbbab4ef6235a31ce66e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= Date: Fri, 26 Jul 2019 22:30:35 +0200 Subject: [PATCH] Show the progress of the file tree scanning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: François Bobot --- src/file_tree.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/file_tree.ml b/src/file_tree.ml index 994bcbaf198b..8f6b0cd6dde6 100644 --- a/src/file_tree.ml +++ b/src/file_tree.ml @@ -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 @@ -347,6 +351,7 @@ 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) @@ -354,8 +359,11 @@ let load ?(warn_when_seeing_jbuild_file=true) path ~ancestor_vcs = ~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) ]