Skip to content

Commit

Permalink
Fix Cyberpunk r6/cache file updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZashIn committed Jan 18, 2025
1 parent 68dc6df commit 481eb48
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions games/game_cyberpunk2077.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,25 +575,27 @@ def _map_cache_files(self):
"""
data_path = Path(self.dataDirectory().absolutePath())
overwrite_path = Path(self._organizer.overwritePath())
cache_files = [
file.relative_to(data_path) for file in data_path.glob("r6/cache/*")
]
data_cache_path = data_path / "r6/cache"
overwrite_cache_path = overwrite_path / "r6/cache"
cache_files = (
file.relative_to(data_path) for file in data_cache_path.glob("*")
)
if self._get_setting("clear_cache_after_game_update") and any(
self._is_cache_file_updated(file, data_path) for file in cache_files
):
qInfo('Updated game files detected, clearing "overwrite/r6/cache/*"')
try:
shutil.rmtree(overwrite_path / "r6/cache")
shutil.rmtree(overwrite_cache_path)
except FileNotFoundError:
pass
new_cache_files = cache_files
qInfo('Updating "r6/cache" in overwrite')
shutil.copytree(data_cache_path, overwrite_cache_path, dirs_exist_ok=True)
else:
new_cache_files = list(self._unmapped_cache_files(data_path))
for file in new_cache_files:
qInfo(f'Copying "{file}" to overwrite (to catch file overwrites)')
dst = overwrite_path / file
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(data_path / file, dst)
for file in self._unmapped_cache_files(data_path):
qInfo(f'Copying "{file}" to overwrite (to catch file overwrites)')
dst = overwrite_path / file
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(data_path / file, dst)

def _is_cache_file_updated(self, file: Path, data_path: Path) -> bool:
"""Checks if a cache file is updated (in game dir).
Expand Down

0 comments on commit 481eb48

Please sign in to comment.