let xpointer_RE = Pcre.regexp "#.*$"
+let file_scheme_RE = Pcre.regexp "^file://"
let clean_owner_environment () =
let dbd = instance () in
(fun uri ->
let uri = Pcre.replace ~rex:xpointer_RE ~templ:"" uri in
List.iter
- (fun suffix ->
- (*prerr_endline ("unregistering " ^ uri ^ suffix);*)
- Http_getter.unregister (uri ^ suffix))
-
+ (fun suffix ->
+ try
+ MatitaMisc.safe_remove (Http_getter.resolve (uri ^ suffix))
+ with Http_getter_types.Key_not_found _ -> ())
[""; ".body"; ".types"])
owned_uris;
List.iter (fun statement ->
let status = Mysql.status dbd in
match status with
| Mysql.StatusError Mysql.Table_exists_error -> ()
+ | Mysql.StatusError Mysql.Dup_keyname -> ()
| Mysql.StatusError _ -> raise exn
| _ -> ()
) statements
(* removes uri from the ownerized tables, and returns the list of other objects
* (theyr uris) that ref the one removed.
* AFAIK there is no need to return it, since the MatitaTypes.staus should
- * contain all defined objects. but to double ckeck we do not garbage the
+ * contain all defined objects. but to double check we do not garbage the
* metadata...
*)
let remove_uri uri =
let l = ref [] in
Mysql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l := a:: !l);
let l = List.sort Pervasives.compare !l in
- let rec uniq = function
- | [] -> []
- | h::[] -> [h]
- | h1::h2::tl when h1 = h2 -> uniq (h2 :: tl)
- | h1::tl (* when h1 <> h2 *) -> h1 :: uniq tl
- in
- uniq l
+ MatitaMisc.list_uniq l
with
exn -> raise exn (* no errors should be accepted *)
+let xpointers_of_ind uri =
+ let dbd = instance () in
+ let name_tbl = MetadataTypes.name_tbl () in
+ let query = sprintf
+ "SELECT source FROM %s WHERE source LIKE '%s#xpointer%%'" name_tbl
+ (Mysql.escape (UriManager.string_of_uri uri))
+ in
+ let rc = Mysql.exec dbd query in
+ let l = ref [] in
+ Mysql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l := a:: !l);
+ List.map UriManager.uri_of_string !l
+