mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
fix(relink): keep sha untouched during relinking
This commit is contained in:
@@ -344,15 +344,6 @@ class MetadataSyncService:
|
||||
+ (f" with version: {model_version_id}" if model_version_id else "")
|
||||
)
|
||||
|
||||
primary_model_file: Optional[Dict[str, Any]] = None
|
||||
for file_info in civitai_metadata.get("files", []):
|
||||
if file_info.get("primary", False) and file_info.get("type") == "Model":
|
||||
primary_model_file = file_info
|
||||
break
|
||||
|
||||
if primary_model_file and primary_model_file.get("hashes", {}).get("SHA256"):
|
||||
metadata["sha256"] = primary_model_file["hashes"]["SHA256"].lower()
|
||||
|
||||
metadata_path = os.path.splitext(file_path)[0] + ".metadata.json"
|
||||
await self.update_model_metadata(
|
||||
metadata_path,
|
||||
|
||||
@@ -373,7 +373,7 @@ async def test_fetch_and_update_model_returns_rate_limit_error(tmp_path):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_relink_metadata_fetches_version_and_updates_sha(tmp_path):
|
||||
async def test_relink_metadata_fetches_version_without_overwriting_sha(tmp_path):
|
||||
provider = SimpleNamespace(
|
||||
get_model_by_hash=AsyncMock(),
|
||||
get_model_version=AsyncMock(
|
||||
@@ -393,7 +393,7 @@ async def test_relink_metadata_fetches_version_and_updates_sha(tmp_path):
|
||||
|
||||
helpers = build_service(default_provider=provider)
|
||||
|
||||
metadata = {"model_name": "Local"}
|
||||
metadata = {"model_name": "Local", "sha256": "original"}
|
||||
result = await helpers.service.relink_metadata(
|
||||
file_path=str(tmp_path / "model.safetensors"),
|
||||
metadata=metadata,
|
||||
@@ -401,7 +401,8 @@ async def test_relink_metadata_fetches_version_and_updates_sha(tmp_path):
|
||||
model_version_id=2,
|
||||
)
|
||||
|
||||
assert result["sha256"] == "abcdef"
|
||||
assert result["model_name"] == "Remote"
|
||||
assert result["sha256"] == "original"
|
||||
helpers.metadata_manager.save_metadata.assert_awaited_once()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user