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