fix: support GGUF model deletion in model lifecycle service

- Add optional main_extension parameter to delete_model_artifacts function
- Extract file extension from model filename to handle different file types
- Update model scanner to pass file extension when deleting models
- Add test case for GGUF file deletion to ensure proper cleanup
- Maintain backward compatibility with existing safetensors models

This change allows the model lifecycle service to properly delete GGUF model files along with their associated metadata and preview files, expanding support beyond just safetensors format.
This commit is contained in:
Will Miao
2025-11-19 10:36:03 +08:00
parent 6d95e93378
commit b75baa1d1a
3 changed files with 55 additions and 11 deletions

View File

@@ -1444,11 +1444,13 @@ class ModelScanner:
for file_path in file_paths:
try:
target_dir = os.path.dirname(file_path)
file_name = os.path.splitext(os.path.basename(file_path))[0]
base_name = os.path.basename(file_path)
file_name, main_extension = os.path.splitext(base_name)
deleted_files = await delete_model_artifacts(
target_dir,
file_name
file_name,
main_extension=main_extension,
)
if deleted_files: