Rename Path.readdir to Path.readdir_unsorted (#828)
As `Sys.readdir`, it returns entries in an nondeterministic order. This can cause problems if caller relies on the list being sorted. See #820. Signed-off-by: Etienne Millon <etienne@cryptosense.com>
This commit is contained in:
parent
8fea39b09b
commit
e97d0c5ad6
|
@ -676,7 +676,7 @@ module Promotion = struct
|
||||||
let do_promote db =
|
let do_promote db =
|
||||||
let by_targets = group_by_targets db in
|
let by_targets = group_by_targets db in
|
||||||
let potential_build_contexts =
|
let potential_build_contexts =
|
||||||
match Path.readdir Path.build_dir with
|
match Path.readdir_unsorted Path.build_dir with
|
||||||
| exception _ -> []
|
| exception _ -> []
|
||||||
| files ->
|
| files ->
|
||||||
List.filter_map files ~f:(fun fn ->
|
List.filter_map files ~f:(fun fn ->
|
||||||
|
|
|
@ -408,7 +408,7 @@ let get_dir_status t ~dir =
|
||||||
Dir_status.Loaded Path.Set.empty
|
Dir_status.Loaded Path.Set.empty
|
||||||
else if not (Path.is_local dir) then
|
else if not (Path.is_local dir) then
|
||||||
Dir_status.Loaded
|
Dir_status.Loaded
|
||||||
(match Path.readdir dir with
|
(match Path.readdir_unsorted dir with
|
||||||
| exception _ -> Path.Set.empty
|
| exception _ -> Path.Set.empty
|
||||||
| files ->
|
| files ->
|
||||||
Path.Set.of_list (List.map files ~f:(Path.relative dir)))
|
Path.Set.of_list (List.map files ~f:(Path.relative dir)))
|
||||||
|
@ -637,7 +637,7 @@ let remove_old_artifacts t ~dir ~subdirs_to_keep =
|
||||||
Hashtbl.mem t.files (Path.relative dir Config.jbuilder_keep_fname) then
|
Hashtbl.mem t.files (Path.relative dir Config.jbuilder_keep_fname) then
|
||||||
()
|
()
|
||||||
else
|
else
|
||||||
match Path.readdir dir with
|
match Path.readdir_unsorted dir with
|
||||||
| exception _ -> ()
|
| exception _ -> ()
|
||||||
| files ->
|
| files ->
|
||||||
List.iter files ~f:(fun fn ->
|
List.iter files ~f:(fun fn ->
|
||||||
|
|
|
@ -180,7 +180,7 @@ let load ?(extra_ignored_subtrees=Path.Set.empty) path =
|
||||||
let rec walk path ~dirs_visited ~project ~ignored : Dir.t =
|
let rec walk path ~dirs_visited ~project ~ignored : Dir.t =
|
||||||
let contents = lazy (
|
let contents = lazy (
|
||||||
let files, sub_dirs =
|
let files, sub_dirs =
|
||||||
Path.readdir path
|
Path.readdir_unsorted path
|
||||||
|> List.filter_partition_map ~f:(fun fn ->
|
|> List.filter_partition_map ~f:(fun fn ->
|
||||||
let path = Path.relative path fn in
|
let path = Path.relative path fn in
|
||||||
let is_directory, file =
|
let is_directory, file =
|
||||||
|
|
|
@ -465,7 +465,7 @@ let explode_exn t =
|
||||||
let exists t =
|
let exists t =
|
||||||
try Sys.file_exists (to_string t)
|
try Sys.file_exists (to_string t)
|
||||||
with Sys_error _ -> false
|
with Sys_error _ -> false
|
||||||
let readdir t = Sys.readdir (to_string t) |> Array.to_list
|
let readdir_unsorted t = Sys.readdir (to_string t) |> Array.to_list
|
||||||
let is_directory t =
|
let is_directory t =
|
||||||
try Sys.is_directory (to_string t)
|
try Sys.is_directory (to_string t)
|
||||||
with Sys_error _ -> false
|
with Sys_error _ -> false
|
||||||
|
|
|
@ -128,7 +128,7 @@ val split_first_component : t -> (string * t) option
|
||||||
val insert_after_build_dir_exn : t -> string -> t
|
val insert_after_build_dir_exn : t -> string -> t
|
||||||
|
|
||||||
val exists : t -> bool
|
val exists : t -> bool
|
||||||
val readdir : t -> string list
|
val readdir_unsorted : t -> string list
|
||||||
val is_directory : t -> bool
|
val is_directory : t -> bool
|
||||||
val rmdir : t -> unit
|
val rmdir : t -> unit
|
||||||
val unlink : t -> unit
|
val unlink : t -> unit
|
||||||
|
|
Loading…
Reference in New Issue