From 67163c2224007ceac38d804ebd708bf89da5cb62 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 9 Mar 2024 19:49:05 +1100 Subject: [PATCH] fix(mm): only move model files if necessary The old logic to check if a model needed to be moved relied on the model path being a relative path. Paths are now absolute, causing this check to fail. We then assumed the paths were different and moved the model from its current location to, well, its current location. Use more resilient method to check if a model should be moved. --- .../app/services/model_install/model_install_default.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index b7c581ad450..401fd24a685 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -513,10 +513,17 @@ def _sync_model_path(self, key: str) -> AnyModelConfig: old_path = Path(model.path) models_dir = self.app_config.models_path - if not old_path.is_relative_to(models_dir): + try: + old_path.relative_to(models_dir) return model + except ValueError: + pass new_path = models_dir / model.base.value / model.type.value / model.name + + if old_path == new_path: + return model + self._logger.info(f"Moving {model.name} to {new_path}.") new_path = self._move_model(old_path, new_path) model.path = new_path.as_posix()