diff --git a/otherlibs/dune-site/src/plugins/plugins.ml b/otherlibs/dune-site/src/plugins/plugins.ml index b65e3de1b1d9..654bf68f7d35 100644 --- a/otherlibs/dune-site/src/plugins/plugins.ml +++ b/otherlibs/dune-site/src/plugins/plugins.ml @@ -1,11 +1,22 @@ open Dune_site.Private_ module Data = Dune_site_plugins_data -let readdir dirs = - List.concat - (List.map - (fun dir -> Array.to_list (Sys.readdir dir)) - (List.filter Sys.file_exists dirs)) +let meta_fn = "META" + +let readdir = + let ( / ) = Filename.concat in + let readdir_noexn dir = + try Sys.readdir dir with + | Sys_error _ -> [||] + in + fun dirs -> + List.concat + (List.map + (fun dir -> + List.filter + (fun entry -> Sys.file_exists (dir / entry / meta_fn)) + (Array.to_list (readdir_noexn dir))) + dirs) ;; let rec lookup dirs file = @@ -208,8 +219,6 @@ let load file ~pkg = { Meta_parser.name = Some pkg; entries } ;; -let meta_fn = "META" - let lookup_and_load_one_dir ~dir ~pkg = let meta_file = Filename.concat dir meta_fn in if Sys.file_exists meta_file diff --git a/otherlibs/dune-site/test/opam-uninstall.t b/otherlibs/dune-site/test/opam-uninstall.t index f75b0fb971a2..97a442f090c9 100644 --- a/otherlibs/dune-site/test/opam-uninstall.t +++ b/otherlibs/dune-site/test/opam-uninstall.t @@ -92,6 +92,5 @@ issue by recreating this empty directory. $ mkdir -p _install/lib/app/plugins/plugin1 $ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/app - Fatal error: exception The plugin "plugin1" can't be found in the search paths "$TESTCASE_ROOT/_install/lib/app/plugins". - [2] + Main app starts...