fix: model list and remove now find files in subdirectories#372
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #372 +/- ##
==========================================
+ Coverage 53.36% 54.51% +1.14%
==========================================
Files 32 32
Lines 3592 3603 +11
==========================================
+ Hits 1917 1964 +47
+ Misses 1675 1639 -36
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
617f3b0 to
7eab073
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the problem reported in #362 where
comfy model listandcomfy model removeonly looked at files in the top-level model directory. Models stored in subdirectories (like checkpoints/, loras/SD1.5/, etc.) were invisible.The root cause was
list_models()usingpath.iterdir()which only lists immediate children. Changed it topath.rglob("*")so it finds files at any depth. Also handles missing directories gracefully instead of crashing.For
list_command, added a Type column that shows the subdirectory path (e.g. "checkpoints", "loras/SD1.5") so users can see where each model lives.For
remove, the interactive mode now shows relative paths instead of bare filenames, so users can distinguish between models in different subdirectories. Also added path traversal protection (resolve + is_relative_to check) and switched from exists() to is_file() so passing a directory name doesn't crash with IsADirectoryError.Tests cover recursive discovery, missing directory handling, directory exclusion, Type column output, path traversal rejection, directory name rejection, subdirectory removal, and root-level removal.
Closes #362