mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(mm): just delete the dir w/ rmtree when deleting model
This commit is contained in:
@@ -369,11 +369,18 @@ class ModelInstallService(ModelInstallServiceBase):
|
||||
def unconditionally_delete(self, key: str) -> None: # noqa D102
|
||||
model = self.record_store.get_model(key)
|
||||
model_path = self.app_config.models_path / model.path
|
||||
# Models are stored in a directory named by their key. To delete the model on disk, we delete the entire
|
||||
# directory. However, the path we store in the model record may be either a file within the key directory,
|
||||
# or the directory itself. So we have to handle both cases.
|
||||
if model_path.is_file() or model_path.is_symlink():
|
||||
model_path.unlink()
|
||||
# Sanity check - file models should be in their own directory under the models dir. The parent of the
|
||||
# file should be the model's directory, not the Invoke models dir!
|
||||
assert model_path.parent != self.app_config.models_path
|
||||
rmtree(model_path.parent)
|
||||
elif model_path.is_dir():
|
||||
# Sanity check - folder models should be in their own directory under the models dir. The path should
|
||||
# not be the Invoke models dir itself!
|
||||
assert model_path != self.app_config.models_path
|
||||
rmtree(model_path)
|
||||
self.unregister(key)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user