X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaDb.ml;h=b2c97789d22958a88b755802f950e2d197a676f2;hb=eb5345bc1314ca8bf8b9ea2293dbe0aa496b2d69;hp=a6eb73ded475b87fac61ae4fae99806301b11467;hpb=541a200b13431987114dd3fd88ec9764cee1e772;p=helm.git diff --git a/helm/matita/matitaDb.ml b/helm/matita/matitaDb.ml index a6eb73ded..b2c97789d 100644 --- a/helm/matita/matitaDb.ml +++ b/helm/matita/matitaDb.ml @@ -25,7 +25,11 @@ open Printf ;; -let clean_owner_environment dbd owner = +let xpointer_RE = Pcre.regexp "#.*$" + +let clean_owner_environment () = + let dbd = MatitaMisc.dbd_instance () in + let owner = (Helm_registry.get "matita.owner") in let obj_tbl = MetadataTypes.obj_tbl () in let sort_tbl = MetadataTypes.sort_tbl () in let rel_tbl = MetadataTypes.rel_tbl () in @@ -50,28 +54,34 @@ DROP INDEX no_inconcl_aux_no ON no_inconcl_aux (no); DROP INDEX no_concl_hyp_source ON no_concl_hyp (source); DROP INDEX no_concl_hyp_no ON no_concl_hyp (no); *) - (try - MetadataDb.clean ~dbd - with - exn -> - match Mysql.errno dbd with - | Mysql.No_such_table -> () - | _ -> raise exn - | _ -> () - ); + let owned_uris = + try + MetadataDb.clean ~dbd + with Mysql.Error _ as exn -> + match Mysql.errno dbd with + | Mysql.No_such_table -> [] + | _ -> raise exn + in + List.iter + (fun uri -> + let uri = Pcre.replace ~rex:xpointer_RE ~templ:"" uri in + List.iter + (fun suffix -> Http_getter.unregister (uri ^ suffix)) + [""; ".body"; ".types"]) + owned_uris; List.iter (fun statement -> try ignore (Mysql.exec dbd statement) - with - exn -> - match Mysql.errno dbd with - | Mysql.No_such_table -> () - | _ -> raise exn - | _ -> () - ) statements + with Mysql.Error _ as exn -> + match Mysql.errno dbd with + | Mysql.Bad_table_error -> () + | _ -> raise exn + ) statements; ;; -let create_owner_environment dbd owner = +let create_owner_environment () = + let dbd = MatitaMisc.dbd_instance () in + let owner = (Helm_registry.get "matita.owner") in let obj_tbl = MetadataTypes.obj_tbl () in let sort_tbl = MetadataTypes.sort_tbl () in let rel_tbl = MetadataTypes.rel_tbl () in