feat: normalize tags to lowercase for Windows compatibility, see #637

Convert all tags to lowercase in tag processing logic to prevent case sensitivity issues on Windows filesystems. This ensures consistent tag matching and prevents duplicate tags with different cases from being created.

Changes include:
- TagUpdateService now converts tags to lowercase before comparison
- Utils function converts model tags to lowercase before priority resolution
- Test cases updated to reflect lowercase tag expectations
This commit is contained in:
Will Miao
2025-11-04 12:54:09 +08:00
parent 6c03aa1430
commit 3d6bb432c4
5 changed files with 154 additions and 5 deletions

View File

@@ -240,7 +240,7 @@ def test_download_coordinator_emits_progress() -> None:
def test_tag_update_service_adds_unique_tags(tmp_path: Path) -> None:
metadata_path = tmp_path / "model.metadata.json"
metadata_path.write_text(json.dumps({"tags": ["Existing"]}))
metadata_path.write_text(json.dumps({"tags": ["existing"]}))
async def loader(path: str) -> Dict[str, Any]:
return json.loads(Path(path).read_text())
@@ -258,12 +258,12 @@ def test_tag_update_service_adds_unique_tags(tmp_path: Path) -> None:
tags = asyncio.run(
service.add_tags(
file_path=str(tmp_path / "model.safetensors"),
new_tags=["New", "existing"],
new_tags=["new", "existing"],
metadata_loader=loader,
update_cache=update_cache,
)
)
assert tags == ["Existing", "New"]
assert tags == ["existing", "new"]
assert manager.saved
assert cache_updates