Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: cancel failed download task

Vanalite48f893232884
diff --git a/src-tauri/src/core/downloads/commands.rs b/src-tauri/src/core/downloads/commands.rs
index a24ae32f0..741084e68 100644
--- a/src-tauri/src/core/downloads/commands.rs
+++ b/src-tauri/src/core/downloads/commands.rs
@@ -18,8 +18,9 @@ pub async fn download_files<R: Runtime>(
let cancel_token = CancellationToken::new();
{
let mut download_manager = state.download_manager.lock().await;
- if download_manager.cancel_tokens.contains_key(task_id) {
- return Err(format!("task_id {task_id} exists"));
+ if let Some(existing_token) = download_manager.cancel_tokens.remove(task_id) {
+ log::info!("Cancelling existing download task: {task_id}");
+ existing_token.cancel();
}
download_manager
.cancel_tokens