File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
invokeai/app/services/model_install Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -369,11 +369,18 @@ def delete(self, key: str) -> None: # noqa D102
369369 def unconditionally_delete (self , key : str ) -> None : # noqa D102
370370 model = self .record_store .get_model (key )
371371 model_path = self .app_config .models_path / model .path
372+ # Models are stored in a directory named by their key. To delete the model on disk, we delete the entire
373+ # directory. However, the path we store in the model record may be either a file within the key directory,
374+ # or the directory itself. So we have to handle both cases.
372375 if model_path .is_file () or model_path .is_symlink ():
373- model_path .unlink ()
376+ # Sanity check - file models should be in their own directory under the models dir. The parent of the
377+ # file should be the model's directory, not the Invoke models dir!
374378 assert model_path .parent != self .app_config .models_path
375379 rmtree (model_path .parent )
376380 elif model_path .is_dir ():
381+ # Sanity check - folder models should be in their own directory under the models dir. The path should
382+ # not be the Invoke models dir itself!
383+ assert model_path != self .app_config .models_path
377384 rmtree (model_path )
378385 self .unregister (key )
379386
You can’t perform that action at this time.
0 commit comments