mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
21 lines
682 B
Rust
21 lines
682 B
Rust
use std::env;
|
|
use std::fs;
|
|
use std::io::copy;
|
|
use std::path::Path;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let out_dir = env::var("OUT_DIR")?;
|
|
let out_path = Path::new(&out_dir).join("all.bin");
|
|
if !out_path.exists() {
|
|
println!("cargo:warning=Downloading dictionary file...");
|
|
let mut response =
|
|
ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin")
|
|
.call()?;
|
|
let mut response = response.body_mut().as_reader();
|
|
let mut file = fs::File::create(&out_path)?;
|
|
copy(&mut response, &mut file)?;
|
|
}
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
Ok(())
|
|
}
|