Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions invokeai/app/services/model_install/model_install_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,12 @@ def unconditionally_delete(self, key: str) -> None: # noqa D102
# 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():
# 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)
# Delete the individual model file, not the entire parent directory.
# Other unrelated files may exist in the same directory.
model_path.unlink()
# Clean up the parent directory only if it is now empty
if model_path.parent != self.app_config.models_path and not any(model_path.parent.iterdir()):
model_path.parent.rmdir()
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!
Expand Down
Loading