From: Siraaj Khandkar Date: Wed, 14 Nov 2018 17:34:13 +0000 (-0500) Subject: Handle directories with no regular-file children X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=c66266c608c952190ad5fc8b82882cf15013ce26;p=dups.git Handle directories with no regular-file children i.e. keep exploring child directories when no files remain to process --- diff --git a/dups.ml b/dups.ml index a1dca83..46e8b91 100644 --- a/dups.ml +++ b/dups.ml @@ -58,25 +58,16 @@ end = struct () ) in - let next_dir () = - match Queue.take dirs with - | exception Queue.Empty -> - () - | dir -> - explore dir - in - let next_file () = - match Queue.take files with - | exception Queue.Empty -> - None - | file_path -> - Some file_path - in explore root; - Stream.create (fun () -> - next_dir (); - next_file () - ) + let rec next () = + match Queue.is_empty files, Queue.is_empty dirs with + | false, _ -> Some (Queue.take files) + | true , true -> None + | true , false -> + explore (Queue.take dirs); + next () + in + Stream.create next end type input =