From fec296e41d31122a4acbc87f7d14930cc0a9f210 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:32:05 +1000 Subject: [PATCH] fix(app): move (not copy) models from install tmpdir to destination It's not clear why we were copying downloaded models to the destination dir instead of moving them. I cannot find a reason for it, and I am able to install single-file and diffusers models just fine with the change. This fixes an issue where model installation requires 2x the model's size (bc we were copying the model over). --- .../model_install/model_install_default.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index 81836f7fde..3c236684e8 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -7,7 +7,7 @@ import threading import time from pathlib import Path from queue import Empty, Queue -from shutil import copyfile, copytree, move, rmtree +from shutil import move, rmtree from tempfile import mkdtemp from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union @@ -193,7 +193,7 @@ class ModelInstallService(ModelInstallServiceBase): self.app_config.models_path / info.base.value / info.type.value / (preferred_name or model_path.name) ) try: - new_path = self._copy_model(model_path, dest_path) + new_path = self._move_model(model_path, dest_path) except FileExistsError as excp: raise DuplicateModelException( f"A model named {model_path.name} is already installed at {dest_path.as_posix()}" @@ -618,16 +618,6 @@ class ModelInstallService(ModelInstallServiceBase): self.record_store.update_model(key, ModelRecordChanges(path=model.path)) return model - def _copy_model(self, old_path: Path, new_path: Path) -> Path: - if old_path == new_path: - return old_path - new_path.parent.mkdir(parents=True, exist_ok=True) - if old_path.is_dir(): - copytree(old_path, new_path) - else: - copyfile(old_path, new_path) - return new_path - def _move_model(self, old_path: Path, new_path: Path) -> Path: if old_path == new_path: return old_path