Added metadata merging for inferred directories, needs testing

This commit is contained in:
2025-11-26 23:52:30 +03:00
parent 684d584402
commit 0d618be4b5

View File

@@ -60,11 +60,17 @@ let find path tree =
| _ -> failwith "cannot search non-directory" | _ -> failwith "cannot search non-directory"
in aux (p, tree) in aux (p, tree)
let add_child name node map =
match (NameMap.find_opt name map, node) with
| Some (InferredDirectory (children, _)), Directory (_, md) ->
NameMap.add name (Directory (children, md)) map
| _ -> NameMap.add name node map
(* TODO: add logic for links, device nodes, and replacing inferred directories *)
let add_direct name node = function let add_direct name node = function
| InferredDirectory (map, md) -> | InferredDirectory (map, md) ->
InferredDirectory ((NameMap.add name node map), md) InferredDirectory ((add_child name node map), md)
| Directory (map, md) -> | Directory (map, md) ->
Directory ((NameMap.add name node map), md) Directory ((add_child name node map), md)
| _ -> | _ ->
Printf.printf "whatever the fuck %s" name; Directory (NameMap.empty, empty_dir_metadata) Printf.printf "whatever the fuck %s" name; Directory (NameMap.empty, empty_dir_metadata)