From 031d5e4f40f8d53510e1087aa9b06bb29883f881 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Mon, 18 May 2026 13:57:28 +0800 Subject: [PATCH] fix(doctor): exclude checkpoints/embeddings from duplicate filename detection (#934) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Duplicate filename detection is only relevant for LoRAs, which use basename-only syntax (). Checkpoints and diffusion models reference files via relative paths with extensions, so filename conflicts there are false positives — there is no resolution ambiguity. Both _log_duplicate_filename_summary() and DoctorHandler's _check_filename_conflicts() now skip scanners with model_type != 'lora'. --- py/routes/handlers/misc_handlers.py | 6 ++++++ py/services/model_scanner.py | 5 ++++- tests/services/test_model_scanner.py | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/py/routes/handlers/misc_handlers.py b/py/routes/handlers/misc_handlers.py index 73b8da72..6238a228 100644 --- a/py/routes/handlers/misc_handlers.py +++ b/py/routes/handlers/misc_handlers.py @@ -995,6 +995,12 @@ class DoctorHandler: total_conflict_files = 0 for model_type, label, factory in self._scanner_factories: + # Duplicate filename detection targets LoRAs which use basename-only + # syntax (). Checkpoints/embeddings reference + # models via relative paths with extensions, so conflicts there would + # be false positives. + if model_type != "lora": + continue try: scanner = await factory() hash_index = getattr(scanner, "_hash_index", None) diff --git a/py/services/model_scanner.py b/py/services/model_scanner.py index fa05e0ee..e2257674 100644 --- a/py/services/model_scanner.py +++ b/py/services/model_scanner.py @@ -1101,7 +1101,10 @@ class ModelScanner: def _log_duplicate_filename_summary(self) -> None: """Log a batched summary of duplicate filename conflicts once per scan.""" - if self._hash_index is None: + # Duplicate filename detection is only relevant for LoRAs, which use + # basename-only syntax (). Checkpoints and embeddings + # use full relative paths for resolution, so conflicts are not ambiguous. + if self._hash_index is None or self.model_type != "lora": return duplicates = self._hash_index.get_duplicate_filenames() diff --git a/tests/services/test_model_scanner.py b/tests/services/test_model_scanner.py index 84b4693a..c0141439 100644 --- a/tests/services/test_model_scanner.py +++ b/tests/services/test_model_scanner.py @@ -636,6 +636,8 @@ async def test_log_duplicate_filename_summary_logs_warning(tmp_path: Path, caplo root = tmp_path / "loras" root.mkdir() scanner = DummyScanner(root) + # Duplicate filename detection is only active for LoRAs + scanner.model_type = "lora" # Simulate duplicate filenames in the hash index scanner._hash_index.add_entry("aaa111", str(root / "model.safetensors")) @@ -646,7 +648,7 @@ async def test_log_duplicate_filename_summary_logs_warning(tmp_path: Path, caplo assert len(caplog.records) >= 1 log_msg = caplog.records[-1].message assert "Duplicate filename conflict detected" in log_msg - assert "1 dummy filename(s)" in log_msg + assert "1 lora filename(s)" in log_msg assert "2 files total" in log_msg