fix: better cache folder detection with nested subfolder support

- Now checks 2 levels deep for TGA files (handles version subfolders like 19.3.2.201024)
- convert_cache_folder now uses rglob to find TGA files in all subfolders
- Will auto-detect the version folder in ProgramData
This commit is contained in:
LemonNexus 2026-02-11 16:45:31 +00:00
parent 6983d74f34
commit c4aab56a9e
1 changed files with 28 additions and 14 deletions

View File

@ -88,18 +88,32 @@ class TGAConverter:
"""
# Check default locations
for path in self.DEFAULT_CACHE_PATHS:
if path.exists():
# Check if this folder directly contains .tga files
if list(path.glob("*.tga")):
logger.info(f"Found cache folder: {path}")
self._cache_path = path
return path
# Check for subfolders (version folders like "19.3.2.201024")
for subfolder in path.iterdir():
if subfolder.is_dir() and list(subfolder.glob("*.tga")):
logger.info(f"Found cache subfolder: {subfolder}")
self._cache_path = subfolder
return subfolder
if not path.exists():
continue
# Check if this folder directly contains .tga files
if list(path.glob("*.tga")):
logger.info(f"Found cache folder: {path}")
self._cache_path = path
return path
# Check for subfolders (version folders like "19.3.2.201024")
for subfolder in path.iterdir():
if not subfolder.is_dir():
continue
# Check if subfolder contains .tga files
if list(subfolder.glob("*.tga")):
logger.info(f"Found cache subfolder: {subfolder}")
self._cache_path = subfolder
return subfolder
# Check one level deeper (in case of nested structure)
for nested in subfolder.iterdir():
if nested.is_dir() and list(nested.glob("*.tga")):
logger.info(f"Found cache nested folder: {nested}")
self._cache_path = nested
return nested
# Try to find by looking for .tga files
logger.info("Searching for .tga files...")
@ -373,8 +387,8 @@ class TGAConverter:
logger.error("Cache folder not found")
return results
# Find all TGA files
tga_files = list(cache_path.glob("*.tga"))
# Find all TGA files (including in subfolders)
tga_files = list(cache_path.rglob("*.tga"))
if not tga_files:
logger.warning(f"No .tga files found in: {cache_path}")