mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
allow removal of models with legacy relative path addressing
This commit is contained in:
parent
faa1ffb06f
commit
a17021ba0c
@ -342,7 +342,7 @@ class ModelInstallService(ModelInstallServiceBase):
|
|||||||
"""Unregister the model. Delete its files only if they are within our models directory."""
|
"""Unregister the model. Delete its files only if they are within our models directory."""
|
||||||
model = self.record_store.get_model(key)
|
model = self.record_store.get_model(key)
|
||||||
models_dir = self.app_config.models_path
|
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):
|
if model_path.is_relative_to(models_dir):
|
||||||
self.unconditionally_delete(key)
|
self.unconditionally_delete(key)
|
||||||
else:
|
else:
|
||||||
@ -350,7 +350,7 @@ class ModelInstallService(ModelInstallServiceBase):
|
|||||||
|
|
||||||
def unconditionally_delete(self, key: str) -> None: # noqa D102
|
def unconditionally_delete(self, key: str) -> None: # noqa D102
|
||||||
model = self.record_store.get_model(key)
|
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():
|
if model_path.is_dir():
|
||||||
rmtree(model_path)
|
rmtree(model_path)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user