This commit is contained in:
Googlefan
2025-02-23 04:52:02 +00:00
parent 6c5ea9adce
commit 6fc97b1f33
3 changed files with 19 additions and 59 deletions

View File

@@ -43,5 +43,4 @@ aivmx = ["npyz", "base64"]
base64 = ["dep:base64"]
[build-dependencies]
ureq = "3.0.6"
home-dir = "0.1.0"
ureq = "3.0.6"

View File

@@ -1,17 +1,12 @@
use std::env;
use std::fs::{self, hard_link};
use std::fs;
use std::io::copy;
use std::path::PathBuf;
use home_dir::HomeDirExt;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = "~/.cache/sbv2-api-assets".expand_home().unwrap();
let out_dir = PathBuf::from(&env::var("OUT_DIR").unwrap());
let out_path = out_dir.join("all.bin");
if !out_path.exists() {
if !out_dir.exists() {
fs::create_dir_all(out_dir).unwrap();
}
println!("cargo:warning=Downloading dictionary file...");
let mut response =
ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin")
@@ -20,11 +15,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut file = fs::File::create(&out_path)?;
copy(&mut response, &mut file)?;
}
hard_link(
out_path,
PathBuf::from(&env::var("OUT_DIR").unwrap()).join("out.bin"),
)
.unwrap();
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}