X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=components%2Flibrary%2FlibraryClean.ml;h=f61fc89c27f0ada471af7926b734f470a5570e28;hb=3638e4f4fbdc00124e97006d47ce2ada952da031;hp=2ac65c5c8b9d2f3435a17fdf10a99a82415d6353;hpb=d90d73349df641ea2d18b4c2ff4fe9d970861778;p=helm.git diff --git a/components/library/libraryClean.ml b/components/library/libraryClean.ml index 2ac65c5c8..f61fc89c2 100644 --- a/components/library/libraryClean.ml +++ b/components/library/libraryClean.ml @@ -49,17 +49,24 @@ let one_step_depend suri = Hashtbl.add cache_of_processed_baseuri buri true; let query = let buri = buri ^ "/" in - let buri = HMysql.escape buri in + let buri = HSql.escape buri in let obj_tbl = MetadataTypes.obj_tbl () in - sprintf - ("SELECT source, h_occurrence FROM %s WHERE " ^^ - "h_occurrence REGEXP '^%s[^/]*$'") - obj_tbl buri + if HSql.isMysql then + sprintf ("SELECT source, h_occurrence FROM %s WHERE " + ^^ "h_occurrence REGEXP '^%s[^/]*$'") obj_tbl buri + else + begin + HLog.debug "Warning SELECT without REGEXP"; + sprintf + ("SELECT source, h_occurrence FROM %s WHERE " ^^ + "h_occurrence LIKE '%s%%'") + obj_tbl buri + end in try - let rc = HMysql.exec (LibraryDb.instance ()) query in + let rc = HSql.exec (LibraryDb.instance ()) query in let l = ref [] in - HMysql.iter rc ( + HSql.iter rc ( fun row -> match row.(0), row.(1) with | Some uri, Some occ when Filename.dirname occ = buri -> @@ -212,18 +219,20 @@ let clean_baseuris ?(verbose=true) buris = List.iter (fun baseuri -> try - HExtlib.safe_remove - (LibraryMisc.obj_file_of_baseuri - ~must_exist:false ~writable:true ~baseuri); + let obj_file = + LibraryMisc.obj_file_of_baseuri ~must_exist:false ~writable:true ~baseuri + in + HExtlib.safe_remove obj_file ; HExtlib.safe_remove (LibraryMisc.metadata_file_of_baseuri - ~must_exist:false ~writable:true ~baseuri); + ~must_exist:false ~writable:true ~baseuri) ; HExtlib.safe_remove (LibraryMisc.lexicon_file_of_baseuri - ~must_exist:false ~writable:true ~baseuri) + ~must_exist:false ~writable:true ~baseuri) ; + HExtlib.rmdir_descend (Filename.chop_extension obj_file) with Http_getter_types.Key_not_found _ -> ()) (HExtlib.list_uniq (List.fast_sort Pervasives.compare - (List.map (UriManager.buri_of_uri) l))); + (List.map (UriManager.buri_of_uri) l @ buris))); List.iter (let last_baseuri = ref "" in fun uri -> @@ -238,14 +247,17 @@ let clean_baseuris ?(verbose=true) buris = end; LibrarySync.remove_obj uri ) l; - cleaned_no := !cleaned_no + List.length l; - if !cleaned_no > 30 then + if HSql.isMysql then begin - cleaned_no := 0; - List.iter - (function table -> - ignore (HMysql.exec (LibraryDb.instance ()) ("OPTIMIZE TABLE " ^ table))) - [MetadataTypes.name_tbl (); MetadataTypes.rel_tbl (); - MetadataTypes.sort_tbl (); MetadataTypes.obj_tbl(); - MetadataTypes.count_tbl()] + cleaned_no := !cleaned_no + List.length l; + if !cleaned_no > 30 then + begin + cleaned_no := 0; + List.iter + (function table -> + ignore (HSql.exec (LibraryDb.instance ()) ("OPTIMIZE TABLE " ^ table))) + [MetadataTypes.name_tbl (); MetadataTypes.rel_tbl (); + MetadataTypes.sort_tbl (); MetadataTypes.obj_tbl(); + MetadataTypes.count_tbl()] + end end