Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

merge: A27 (fix/310-a27-model-folder 8d6fe9e99) into fix/310-issues, folders look-only

purplebf7b340e4209
diff --cc src-tauri/src/commands/download.rs
index 704b9156,ee7ec620..b499e5ee
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@@ -1285,6 -1204,53 +1311,55 @@@ mod chat_download_tests
}
}
+ /// A27: the directories the header may send a main model file to, for a
+ /// download whose folder came from a title. None for any other folder (a
+ /// LoRA, a VAE, an upscaler: their search type says what they are) and for
+ /// a ComfyUI on another machine, whose files LU does not read back.
+ async fn header_folder_dirs(
+ state: &State<'_, AppState>,
+ comfy_path: &Option<String>,
+ subfolder: &str,
+ ) -> Option<HashMap<String, PathBuf>> {
+ if !["checkpoints", "diffusion_models", "unet"].contains(&subfolder) || remote_comfy(state).is_some() {
+ return None;
+ }
+ let mut dirs = HashMap::new();
++ // Look-only (PR #218): settle_by_header creates the one folder a file
++ // moves into, no other main folder is made by a download.
+ for key in crate::commands::model_sniff::HEADER_FOLDERS {
- if let Ok(d) = comfy_models_dir(state, comfy_path, key).await {
++ if let Ok(d) = comfy_models_path(state, comfy_path, key).await {
+ dirs.insert(key.to_string(), d);
+ }
+ }
+ Some(dirs)
+ }
+
+ /// A27: the file of this name in another main model folder, where an earlier
+ /// download of it was moved by its header.
+ fn already_settled(dirs: &HashMap<String, PathBuf>, subfolder: &str, dest_file: &Path) -> Option<PathBuf> {
+ let name = dest_file.file_name()?;
+ dirs.iter()
+ .filter(|(k, _)| k.as_str() != subfolder)
+ .map(|(_, d)| d.join(name))
+ .find(|p| p.is_file() && !p.with_extension("download").exists())
+ }
+
+ /// A27: after a finished transfer, move the file to the folder its header
+ /// names. The new path when it moved.
+ async fn settle_finished(dest_file: &Path, subfolder: &str, dirs: Option<HashMap<String, PathBuf>>) -> Option<PathBuf> {
+ let dirs = dirs?;
+ let file = dest_file.to_path_buf();
+ let guessed = subfolder.to_string();
+ let moved = tauri::async_runtime::spawn_blocking(move || {
+ crate::commands::model_sniff::settle_by_header(&file, &guessed, &dirs)
+ })
+ .await
+ .ok()
+ .flatten()?;
+ println!("[Download] {} is a {} file by its header, moved to {}", dest_file.display(), moved.0, moved.1.display());
+ Some(moved.1)
+ }
+
// Eight arguments since C60's chatOrigin; a Tauri command takes them flat
// from the frontend's object, so they stay arguments.
#[allow(non_snake_case, clippy::too_many_arguments)]