Skip to content

fix: gog game install path detection to prefer stored value - #1808

Merged
utkarshdalal merged 1 commit into
utkarshdalal:masterfrom
joshuatam:fix/gog-game-path-detection
Aug 13, 2026
Merged

fix: gog game install path detection to prefer stored value#1808
utkarshdalal merged 1 commit into
utkarshdalal:masterfrom
joshuatam:fix/gog-game-path-detection

Conversation

@joshuatam

@joshuatam joshuatam commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Description

fix: gog game install path detection to prefer stored value

Recording

N/A

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Prefer the stored GOG install path when resolving game directories, falling back to detection only if the stored value is empty. Previously we always computed the path, which could miss games moved or installed to custom locations.

Review notes

  • Updated two call sites in GOGManager to use game.installPath.ifEmpty { getGameInstallPath(...) } for directory resolution and Explorer launches.
  • No schema or config changes; still checks directory existence.

Written for commit 9cbc6a9. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved game launching by prioritizing the saved installation location.
    • Added a fallback to the detected installation path when no saved location is available.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

GOG executable discovery and Wine launch command construction now prefer the persisted game installPath. Both methods use the computed installation path only when the persisted path is empty.

Changes

GOG path resolution

Layer / File(s) Summary
Persisted install path fallback
app/src/main/java/app/gamenative/service/gog/GOGManager.kt
getInstalledExe and getGogWineStartCommand use the persisted installPath when available. They fall back to the computed installation path when it is empty.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Mergeability Score: 🟡 Moderate · up to 9cbc6

When a stored GOG install path is empty, verification can fail before the computed path is used, causing an otherwise installed game not to launch. The PR is not merge-ready until path resolution occurs before verification.

Possibly related PRs

Suggested reviewers: utkarshdalal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: preferring the stored GOG install path during path detection.
Description check ✅ Passed The description explains the bug fix, identifies the change type, and completes the checklist; no recording is attached.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/main/java/app/gamenative/service/gog/GOGManager.kt`:
- Around line 740-741: The launch flow in GOGManager currently verifies
game.installPath before applying the computed fallback. Resolve the effective
install path with game.installPath.ifEmpty { getGameInstallPath(...) } before
calling verifyInstallation, and update verifyInstallation to validate that
resolved path while preserving the existing failure behavior for invalid
installations.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 36cd661e-d001-4f9d-913a-2d90e96ddb08

📥 Commits

Reviewing files that changed from the base of the PR and between cac1e9c and 9cbc6a9.

📒 Files selected for processing (1)
  • app/src/main/java/app/gamenative/service/gog/GOGManager.kt

Comment on lines +740 to 741
val gameInstallPath = game.installPath.ifEmpty { getGameInstallPath(gameId.toString(), game.title) }
val gameDir = File(gameInstallPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Make the computed-path fallback reachable before verification.

When game.installPath is empty, verifyInstallation(gameId.toString()) runs first and validates the empty stored path. It returns failure before the fallback at Line 740 is used. An installed game with a valid computed path can therefore still fail to launch.

Resolve the effective install path before verification, then make verifyInstallation validate that resolved path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/main/java/app/gamenative/service/gog/GOGManager.kt` around lines 740
- 741, The launch flow in GOGManager currently verifies game.installPath before
applying the computed fallback. Resolve the effective install path with
game.installPath.ifEmpty { getGameInstallPath(...) } before calling
verifyInstallation, and update verifyInstallation to validate that resolved path
while preserving the existing failure behavior for invalid installations.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/src/main/java/app/gamenative/service/gog/GOGManager.kt">

<violation number="1" location="app/src/main/java/app/gamenative/service/gog/GOGManager.kt:599">
P2: Preferring the stored path with `ifEmpty` selects a stale/non-existent `installPath` over a valid computed path, and then forces an early failure return (`""` in `getInstalledExe`, `"explorer.exe"` in `getGogWineStartCommand`) instead of falling back to the computed location. The sibling helper `getScriptInterpreterPartsForLaunch` already guards with an existence check (`game.installPath.isNotEmpty() && File(game.installPath).exists()`). This can happen when external storage is removed/relocated or after a reinstall leaves the DB `installPath` pointing at a path that no longer exists while the title-based path is valid. Align this line with that existing pattern so the stored value is used only when its directory actually exists.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

try {
val game = getGameFromDbById(gameId) ?: return@withContext ""
val installPath = getGameInstallPath(game.id, game.title)
val installPath = game.installPath.ifEmpty { getGameInstallPath(game.id, game.title) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Preferring the stored path with ifEmpty selects a stale/non-existent installPath over a valid computed path, and then forces an early failure return ("" in getInstalledExe, "explorer.exe" in getGogWineStartCommand) instead of falling back to the computed location. The sibling helper getScriptInterpreterPartsForLaunch already guards with an existence check (game.installPath.isNotEmpty() && File(game.installPath).exists()). This can happen when external storage is removed/relocated or after a reinstall leaves the DB installPath pointing at a path that no longer exists while the title-based path is valid. Align this line with that existing pattern so the stored value is used only when its directory actually exists.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/src/main/java/app/gamenative/service/gog/GOGManager.kt, line 599:

<comment>Preferring the stored path with `ifEmpty` selects a stale/non-existent `installPath` over a valid computed path, and then forces an early failure return (`""` in `getInstalledExe`, `"explorer.exe"` in `getGogWineStartCommand`) instead of falling back to the computed location. The sibling helper `getScriptInterpreterPartsForLaunch` already guards with an existence check (`game.installPath.isNotEmpty() && File(game.installPath).exists()`). This can happen when external storage is removed/relocated or after a reinstall leaves the DB `installPath` pointing at a path that no longer exists while the title-based path is valid. Align this line with that existing pattern so the stored value is used only when its directory actually exists.</comment>

<file context>
@@ -596,7 +596,7 @@ class GOGManager @Inject constructor(
         try {
             val game = getGameFromDbById(gameId) ?: return@withContext ""
-            val installPath = getGameInstallPath(game.id, game.title)
+            val installPath = game.installPath.ifEmpty { getGameInstallPath(game.id, game.title) }
 
             // Try V2 structure first (game_$gameId subdirectory)
</file context>

@utkarshdalal
utkarshdalal merged commit a8d472e into utkarshdalal:master Aug 13, 2026
3 checks passed
@joshuatam
joshuatam deleted the fix/gog-game-path-detection branch August 13, 2026 06:55
otufaohumanoide added a commit to otufaohumanoide/GameNative that referenced this pull request Aug 13, 2026
), wishlist webview (utkarshdalal#1812), gamefixes Whisk (utkarshdalal#1813), rec disclosure (utkarshdalal#1814), gog path (utkarshdalal#1808)

Conflito único em QuickMenu.kt: PR utkarshdalal#1698 adicionou a aba POWER ao
bootstrap de foco, região que o fork reescreveu no hardening de gamepad
(spec 2026-08-12-quickmenu-gamepad-pipeline-hardening). Resolução:
mantém requestMenuFocus() do fork e absorve o caso POWER — sem
retrocesso de nenhum dos lados (comentário before/after no local).

Integração pós-merge no código do fork (listas de abas que o upstream
não conhece): orderedTabs (L1/R1), focusTabContentOrRail (item + rail),
backAction. Código do upstream (powercontrol/, quickMenus/, wishlist,
gamefixes, strings) entrou idêntico.
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