X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaDb.ml;h=0c10a81e855463ce12ca15b3dac8e407854dc0ce;hb=63722506a5e378f3e05b46612cb91c132d994082;hp=aef37a2d0bee52f43f54c0374361073cdceb4f36;hpb=7564f3a87499807bfc15bc488bd6452dc0392b62;p=helm.git diff --git a/helm/matita/matitaDb.ml b/helm/matita/matitaDb.ml index aef37a2d0..0c10a81e8 100644 --- a/helm/matita/matitaDb.ml +++ b/helm/matita/matitaDb.ml @@ -37,6 +37,7 @@ let instance = let xpointer_RE = Pcre.regexp "#.*$" +let file_scheme_RE = Pcre.regexp "^file://" let clean_owner_environment () = let dbd = instance () in @@ -65,10 +66,7 @@ let clean_owner_environment () = (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 -> MatitaMisc.safe_remove (uri ^ suffix ^ ".xml.gz")) [""; ".body"; ".types"]) owned_uris; List.iter (fun statement -> @@ -112,7 +110,7 @@ let create_owner_environment () = (* 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 = @@ -138,20 +136,31 @@ let remove_uri uri = [obj_tbl;sort_tbl;rel_tbl;name_tbl;(*conclno_tbl;conclno_hyp_tbl*)count_tbl]; (* and now the debug job *) let dbg_q = - sprintf "SELECT source FROM %s WHERE h_occurrence LIKE '%s%%'" obj_tbl suri + sprintf "SELECT source FROM %s WHERE h_occurrence LIKE '%s%%'" obj_tbl + (Mysql.escape suri) in try let rc = Mysql.exec dbd dbg_q in 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 + +let reset_owner_environment () = + clean_owner_environment (); + create_owner_environment () +