1 module HGT = Http_getter_types;;
2 module HG = Http_getter;;
3 module UM = UriManager;;
4 module TA = TacticAst;;
6 let cache_of_processed_baseuri = Hashtbl.create 1024
8 let one_step_depend suri =
11 UM.buri_of_uri (UM.uri_of_string suri)
12 with UM.IllFormedUri _ -> suri
14 if Hashtbl.mem cache_of_processed_baseuri buri then
18 Hashtbl.add cache_of_processed_baseuri buri true;
20 let buri = buri ^ "/" in
21 let buri = Mysql.escape buri in
22 let obj_tbl = MetadataTypes.obj_tbl () in
24 "SELECT source FROM %s WHERE h_occurrence LIKE '%s%%'" obj_tbl buri
27 let rc = Mysql.exec (MatitaDb.instance ()) query in
29 Mysql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l:=a:: !l);
30 let l = List.sort Pervasives.compare !l in
31 MatitaMisc.list_uniq l
33 exn -> raise exn (* no errors should be accepted *)
37 let safe_buri_of_suri suri =
39 UM.buri_of_uri (UM.uri_of_string suri)
41 UM.IllFormedUri _ -> suri
43 let close_uri_list uri_to_remove =
44 (* to remove an uri you have to remove the whole script *)
47 (List.fast_sort Pervasives.compare
48 (List.map safe_buri_of_suri uri_to_remove))
50 (* cleand the already visided baseuris *)
54 if Hashtbl.mem cache_of_processed_baseuri buri then false
58 (* now calculate the list of objects that belong to these baseuris *)
62 let inhabitants = HG.ls (buri ^ "/") in
63 let inhabitants = List.filter
64 (function HGT.Ls_object _ -> true | _ -> false)
67 let inhabitants = List.map
69 | HGT.Ls_object e -> buri ^ "/" ^ e.HGT.uri
76 (* now we want the list of all uri that depend on them *)
79 (fun acc u -> one_step_depend u @ acc) [] uri_to_remove
83 (List.fast_sort Pervasives.compare depend)
87 let baseuri_of_file file =
88 let ic = open_in file in
89 let stms = CicTextualParser2.parse_statements (Stream.of_channel ic) in
94 | TA.Executable (_, TA.Command (_, TA.Set (_, "baseuri", buri))) ->
95 uri := MatitaMisc.strip_trailing_slash buri
100 let rec fix uris next =
103 | l -> let uris, next = close_uri_list l in fix uris next @ uris
105 let clean_baseuris buris =
106 let l = fix [] buris in
107 let l = MatitaMisc.list_uniq (List.fast_sort Pervasives.compare l) in
108 let l = List.map UriManager.uri_of_string l in
109 List.iter MatitaSync.remove l