From a9f3f1a4b24a1676b2d4e2c9df9a3c8f591fd4ac Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:14:43 +1000 Subject: [PATCH] fix(app): handle model files with periods in their name Previously, we used pathlib's `with_suffix()` method to change add a suffix (e.g. ".safetensors") to a model when installing it. The intention is to add a suffix to the model's name - but that method actually replaces everything after the first period. This can cause different models to be installed under the same name! For example, the FLUX models all end up with the same name: - "FLUX.1 schnell.safetensors" -> "FLUX.safetensors" - "FLUX.1 dev.safetensors" -> "FLUX.safetensors" The fix is easy - append the suffix using string formatting instead of using pathlib. This issue has existed for a long time, but was exacerbated in 075345bffd51704b217bdd41968812b523382610 in which I updated the names of our starter models, adding ".1" to the FLUX model names. Whoops! --- invokeai/app/services/model_install/model_install_default.py | 3 ++- 1 file changed, 2 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 f15552be7a..81836f7fde 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -186,7 +186,8 @@ class ModelInstallService(ModelInstallServiceBase): info: AnyModelConfig = self._probe(Path(model_path), config) # type: ignore if preferred_name := config.name: - preferred_name = Path(preferred_name).with_suffix(model_path.suffix) + # Careful! Don't use pathlib.Path(...).with_suffix - it can will strip everything after the first dot. + preferred_name = f"{preferred_name}{model_path.suffix}" dest_path = ( self.app_config.models_path / info.base.value / info.type.value / (preferred_name or model_path.name)