(* md5 helpers *) let md5_create files reg = let opts = "md5sum " ^ String.concat " " files ^ " > " ^ reg in let rc = Unix.system opts in match rc with | Unix.WEXITED 0 -> () | Unix.WEXITED i -> raise (Failure "Unable to create the md5sums file") | _ -> assert false let md5_check reg = let opts = "md5sum -c " ^ reg in let rc = Unix.system opts in match rc with | Unix.WEXITED 0 -> true | Unix.WEXITED _ -> false | _ -> assert false let reg () = (Lazy.force Http_getter_env.dump_file) ^ ".md5" (* sync checks *) (* maybe should be useda as a fallback *) (* let is_in_sync_date () = let get_last_mod_date f = try (Unix.stat f).Unix.st_mtime with | Unix.Unix_error (Unix.ENOENT, _, _)-> 0.0 in let map_date = get_last_mod_date (Lazy.force Http_getter_env.cic_dbm_real) in let dump_date = get_last_mod_date (Lazy.force Http_getter_env.dump_file) in dump_date < map_date *) let check_hash () = md5_check (reg ()) let create_hash files = md5_create files (reg ())