Skip to content

cyberpunk fix cache crash#215

Open
Kraken0666 wants to merge 2 commits intoModOrganizer2:masterfrom
Kraken0666:fix/cyberpunk2077-cache-fix
Open

cyberpunk fix cache crash#215
Kraken0666 wants to merge 2 commits intoModOrganizer2:masterfrom
Kraken0666:fix/cyberpunk2077-cache-fix

Conversation

@Kraken0666
Copy link
Copy Markdown

Fix FileNotFoundError in Cyberpunk cache detection.

  • Guard Path.samefile() and filecmp.cmp() with existence checks
  • Prevent crash when r6/cache files (e.g. final.redscripts) are missing
  • Ensures MO2 startup does not fail on clean or partially-modded setups

@ZashIn
Copy link
Copy Markdown
Contributor

ZashIn commented Apr 10, 2026

Thx for you PR, but you need to rebase on latest master. Currently, you are reversing several changes.

About your fix: the baseline of your suggestion is to:

  • check game_file.exists() before any .samefile() checks
  • check if backups exists before comparing backup files

I agree with the game_file.exists() check, but the other checks are unnecessary, since the boolean evaluation is from left to right and .findFiles() returns an empty array when no files are found. So this is false with no backup file found:

(
backup_files := self._organizer.findFiles(
file.parent, f"{file.name}.bk"
)
)

@ZashIn
Copy link
Copy Markdown
Contributor

ZashIn commented Apr 10, 2026

So this PR can be simplified into adding

if not game_file.exists():
    return False

after:

game_file = data_path.absolute() / file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants