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
369
369
def unconditionally_delete (self , key : str ) -> None : # noqa D102
370
370
model = self .record_store .get_model (key )
371
371
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.
372
375
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!
374
378
assert model_path .parent != self .app_config .models_path
375
379
rmtree (model_path .parent )
376
380
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
377
384
rmtree (model_path )
378
385
self .unregister (key )
379
386
You can’t perform that action at this time.
0 commit comments