HLog.error (Printf.sprintf "uri %s belongs to a read-only repository" value);
raise (ReadOnlyUri value)
end;
- if not (Http_getter_storage.is_empty value) &&
- opts.clean_baseuri
+ if (not (Http_getter_storage.is_empty value) ||
+ LibraryClean.db_uris_of_baseuri value <> [])
+ && opts.clean_baseuri
then begin
HLog.message ("baseuri " ^ value ^ " is not empty");
HLog.message ("cleaning baseuri " ^ value);
with
UM.IllFormedUri _ -> suri
+let db_uris_of_baseuri buri =
+ let query =
+ let buri = buri ^ "/" in
+ let buri = HSql.escape buri in
+ let obj_tbl = MetadataTypes.name_tbl () in
+ if HSql.isMysql then
+ sprintf ("SELECT source FROM %s WHERE "
+ ^^ "source 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 = HSql.exec (LibraryDb.instance ()) query in
+ let l = ref [] in
+ HSql.iter rc (
+ fun row ->
+ match row.(0) with
+ | Some uri when Filename.dirname uri = buri ->
+ l := uri :: !l
+ | _ -> ());
+ let l = List.sort Pervasives.compare !l in
+ HExtlib.list_uniq l
+ with
+ exn -> raise exn (* no errors should be accepted *)
+;;
+
let close_uri_list uri_to_remove =
(* to remove an uri you have to remove the whole script *)
let buri_to_remove =
HLog.error ("We were listing an invalid buri: " ^ u);
exit 1
in
+ let uri_to_remove_from_db =
+ List.fold_left
+ (fun acc buri -> db_uris_of_baseuri buri @ acc
+ ) [] buri_to_remove
+ in
+ let uri_to_remove = uri_to_remove @ uri_to_remove_from_db in
+ let uri_to_remove =
+ HExtlib.list_uniq (List.sort Pervasives.compare uri_to_remove) in
(* now we want the list of all uri that depend on them *)
let depend =
List.fold_left