mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
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:
@@ -182,3 +182,42 @@ async def test_delete_model_updates_update_service(tmp_path: Path):
|
||||
assert result["success"] is True
|
||||
assert not model_path.exists()
|
||||
assert update_service.calls == [("lora", 42, [1002])]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_model_removes_gguf_file(tmp_path: Path):
|
||||
model_path = tmp_path / "model.gguf"
|
||||
model_path.write_bytes(b"content")
|
||||
|
||||
metadata_path = tmp_path / "model.metadata.json"
|
||||
metadata_path.write_text(json.dumps({}))
|
||||
|
||||
preview_path = tmp_path / "model.preview.png"
|
||||
preview_path.write_bytes(b"preview")
|
||||
|
||||
raw_data = [
|
||||
{
|
||||
"file_path": model_path.as_posix(),
|
||||
"civitai": {"modelId": 1, "id": 10},
|
||||
}
|
||||
]
|
||||
|
||||
scanner = VersionAwareScanner(raw_data)
|
||||
metadata_manager = DummyMetadataManager({"civitai": {"modelId": 1, "id": 10}})
|
||||
|
||||
async def metadata_loader(path: str):
|
||||
return {}
|
||||
|
||||
service = ModelLifecycleService(
|
||||
scanner=scanner,
|
||||
metadata_manager=metadata_manager,
|
||||
metadata_loader=metadata_loader,
|
||||
)
|
||||
|
||||
result = await service.delete_model(model_path.as_posix())
|
||||
|
||||
assert result["success"] is True
|
||||
assert not model_path.exists()
|
||||
assert not metadata_path.exists()
|
||||
assert not preview_path.exists()
|
||||
assert any(item.endswith("model.gguf") for item in result["deleted_files"])
|
||||
|
||||
Reference in New Issue
Block a user