fix(model): handle nested directories in model file removal#46
Merged
Conversation
Verifies that remove_model_files handles subdirectories created during model download. Currently fails because the function only iterates one directory level deep.
Use remove_dir_all for subdirectories so model files in nested paths (created during download) are fully cleaned up instead of silently left behind.
missuo
approved these changes
Apr 6, 2026
missuo
left a comment
Owner
There was a problem hiding this comment.
LGTM. Clean fix with a good test-first approach.
count_files_recursivecorrectly counts files beforeremove_dir_allfor accurate reporting- Test covers the exact scenario (nested subdirectories in model manifest)
- One minor thought:
count_files_recursivesilently returns 0 on read errors — fine for a count helper, just noting it
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.
Summary
remove_model_files()used a shallowread_dirthat only iterated one directory level and skipped subdirectories. Model manifests can specify nested file paths (e.g.subdir/weights.bin), and the download logic creates those subdirectories viacreate_dir_all. When a user deleted a model, files inside subdirectories were silently left behind — the UI reported success but disk space was not freed.remove_dir_allhandling for subdirectories encountered during removalcount_files_recursivehelper to maintain accurate file count reportingTest plan
cargo test --workspacepasses (including newremove_model_files_handles_subdirectoriestest)cargo clippy --workspace --all-targetsclean