Skip to content

fix: only delete individual LoRA file instead of entire parent directory#8954

Merged
lstein merged 3 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/dont_delete_lora_folder
Mar 10, 2026
Merged

fix: only delete individual LoRA file instead of entire parent directory#8954
lstein merged 3 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/dont_delete_lora_folder

Conversation

@Pfannkuchensack
Copy link
Copy Markdown
Collaborator

@Pfannkuchensack Pfannkuchensack commented Mar 9, 2026

Summary

When deleting a file-based model (e.g. LoRA), the previous logic used rmtree on the parent directory, which would delete all files in that folder — even unrelated ones. Now only the specific model file is removed, and the parent directory is cleaned up only if empty afterward.

QA Instructions

  1. Place multiple LoRA .safetensors files in the same directory under the models folder
  2. Register both as models in InvokeAI (in-place)
  3. Delete one of them via the UI
  4. Verify that only the deleted model's file is removed, and the other file remains intact
  5. Delete the second model and verify the now-empty directory is cleaned up

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

When deleting a file-based model (e.g. LoRA), the previous logic used
rmtree on the parent directory, which would delete all files in that
folder — even unrelated ones. Now only the specific model file is
removed, and the parent directory is cleaned up only if empty afterward.
@github-actions github-actions bot added python PRs that change python files services PRs that change app services labels Mar 9, 2026
Copy link
Copy Markdown
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@lstein lstein enabled auto-merge (squash) March 10, 2026 22:23
@lstein lstein merged commit a7b367f into invoke-ai:main Mar 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python PRs that change python files services PRs that change app services

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants