Fix mods view showing wrong download status for name-mismatched mods
_find_folder() used a plain lowercase compare which failed when the server canonical folder name differs from the comparison.json mod name in more than just case (e.g. spaces vs underscores: "NIArms All in One" vs "@NIArms_All_In_One"). These mods showed ✗ even though the pipeline found and linked them correctly. Add a normalized-name fallback (strips non-alphanumeric, same logic as fetcher._normalize_name) so the lookup matches the same way the fetcher resolves mods from the server index. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import TYPE_CHECKING, Optional
|
||||
|
||||
import customtkinter as ctk
|
||||
|
||||
from arma_modlist_tools.fetcher import _normalize_name
|
||||
from gui._constants import COLOR_OK, COLOR_ERROR, COLOR_WARN, COLOR_RUNNING
|
||||
from gui.views.base import BaseView
|
||||
|
||||
@@ -15,15 +16,26 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
def _find_folder(group_dir: Path, mod_name: str) -> Optional[Path]:
|
||||
"""Return the local mod folder path, or None if not downloaded."""
|
||||
"""Return the local mod folder path, or None if not downloaded.
|
||||
|
||||
Matches in priority order:
|
||||
1. Exact folder name ``@{mod_name}``
|
||||
2. Case-insensitive name (handles ``@CBA_A3`` vs ``CBA_A3``)
|
||||
3. Normalized name — strips non-alphanumeric (handles ``@cba_a3`` vs ``CBA A3``)
|
||||
"""
|
||||
if not group_dir.is_dir():
|
||||
return None
|
||||
candidate = group_dir / f"@{mod_name}"
|
||||
if candidate.is_dir():
|
||||
return candidate
|
||||
target = mod_name.lower()
|
||||
target_lower = mod_name.lower()
|
||||
target_norm = _normalize_name(mod_name)
|
||||
for p in group_dir.iterdir():
|
||||
if p.is_dir() and p.name.lstrip("@").lower() == target:
|
||||
if not p.is_dir():
|
||||
continue
|
||||
if p.name.lstrip("@").lower() == target_lower:
|
||||
return p
|
||||
if _normalize_name(p.name) == target_norm:
|
||||
return p
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user