From b79f2f337ef1f8b7ac3cfd9b6fe0d7ecc28cf756 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 17 Mar 2024 14:07:35 -0400 Subject: [PATCH] Allow removal of models with legacy relative path addressing (#5979) * allow removal of models with legacy relative path addressing * fix ruff error --------- Co-authored-by: Lincoln Stein --- invokeai/app/services/model_install/model_install_default.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index 273be6ba4b..4cce678ff3 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -342,7 +342,7 @@ class ModelInstallService(ModelInstallServiceBase): """Unregister the model. Delete its files only if they are within our models directory.""" model = self.record_store.get_model(key) models_dir = self.app_config.models_path - model_path = Path(model.path) + model_path = models_dir / Path(model.path) # handle legacy relative model paths if model_path.is_relative_to(models_dir): self.unconditionally_delete(key) else: @@ -350,7 +350,7 @@ class ModelInstallService(ModelInstallServiceBase): def unconditionally_delete(self, key: str) -> None: # noqa D102 model = self.record_store.get_model(key) - model_path = Path(model.path) + model_path = self.app_config.models_path / model.path if model_path.is_dir(): rmtree(model_path) else: