From 371af90f992acc7bbe2c61e041773c53b3126657 Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:18:09 +0200 Subject: [PATCH] improve model downloading --- core/src/downloader.rs | 2 +- desktop/src-tauri/src/cmd/mod.rs | 7 ++++++- desktop/src-tauri/src/config.rs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/downloader.rs b/core/src/downloader.rs index 6bac7264..f0c11a60 100644 --- a/core/src/downloader.rs +++ b/core/src/downloader.rs @@ -43,7 +43,7 @@ impl Downloader { F: Fn(u64, u64) -> bool, { tracing::debug!("download from {} to {}", url, path.display()); - let res = self.client.get(url).send().await?; + let res = self.client.get(url).send().await?.error_for_status()?; let total_size = res .content_length() .ok_or_eyre(format!("Failed to get content length from '{}'", url))?; diff --git a/desktop/src-tauri/src/cmd/mod.rs b/desktop/src-tauri/src/cmd/mod.rs index ac1a2599..049e13ff 100644 --- a/desktop/src-tauri/src/cmd/mod.rs +++ b/desktop/src-tauri/src/cmd/mod.rs @@ -141,6 +141,7 @@ pub async fn download_model(app_handle: tauri::AppHandle, url: Option) - } else { let mut errors = Vec::new(); for url in DEFAULT_MODEL_URLS { + tracing::debug!("Download default model from URL {}", url); match downloader .download(url, model_path.to_owned(), download_progress_callback.clone()) .await @@ -152,7 +153,11 @@ pub async fn download_model(app_handle: tauri::AppHandle, url: Option) - } } } - bail!("Could not download any model file. Errors: {:?}", errors); + bail!( + "Could not download any model file. Errors: {:?}\nTried from {:?}", + errors, + DEFAULT_MODEL_URLS.join(",") + ); } } diff --git a/desktop/src-tauri/src/config.rs b/desktop/src-tauri/src/config.rs index 5d8eb0e0..5415079f 100644 --- a/desktop/src-tauri/src/config.rs +++ b/desktop/src-tauri/src/config.rs @@ -4,7 +4,7 @@ pub const DEFAULT_LOG_DIRECTIVE: &str = "vibe=DEBUG,vibe_core=DEBUG,whisper_rs=I pub const STORE_FILENAME: &str = "app_config.json"; pub const DEFAULT_MODEL_URLS: &[&str] = &[ "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium-q8_0.bin", - "https://github.com/thewh1teagle/vibe/releases/download/v0.0.1/ggml-medium.bin", + "https://github.com/thewh1teagle/vibe/releases/download/v0.0.1/ggml-medium-q8_0.bin", ]; pub const DEAFULT_MODEL_FILENAME: &str = "ggml-medium-q8_0.bin";