Skip to content

Adding a check if the app is steam, forcing internal path for steam c…#493

Open
jks211 wants to merge 3 commits intoutkarshdalal:masterfrom
jks211:non-steam-external-storage-fix
Open

Adding a check if the app is steam, forcing internal path for steam c…#493
jks211 wants to merge 3 commits intoutkarshdalal:masterfrom
jks211:non-steam-external-storage-fix

Conversation

@jks211
Copy link

@jks211 jks211 commented Feb 5, 2026

…lient reference for non-steam apps


Summary by cubic

Fixes app directory selection for steamclient DLL by detecting Steam vs non-Steam from the container source. Non-Steam apps always use the internal path; Steam apps use external storage only when enabled or already present.

  • Bug Fixes
    • Added steamApp flag to getAppDirPath: internal for non-Steam; external for Steam when allowed.
    • Updated replaceSteamclientDll to derive GameSource from the container and pass the Steam check.
    • Respects legacy installs by checking existing internal paths before external.

Written for commit 902eeda. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Improved storage path resolution to differentiate Steam-sourced apps from others, preferring external storage for Steam apps when configured while preserving legacy internal-first behavior and existing fallbacks.
    • Updated utilities to route directory lookups based on app source so Steam apps resolve to the appropriate installation path.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Added an overloaded getAppDirPath(gameId: Int, steamApp: Boolean) in SteamService and updated SteamUtils to call it with a GameSource-derived flag, changing app directory selection to consider steamApp when choosing internal vs external storage paths.

Changes

Cohort / File(s) Summary
SteamService API Extension
app/src/main/java/app/gamenative/service/SteamService.kt
Added getAppDirPath(gameId: Int, steamApp: Boolean) that preserves legacy internal-first checks and conditionally prefers external paths when steamApp is true and external storage is enabled.
SteamUtils Integration
app/src/main/java/app/gamenative/utils/SteamUtils.kt
Imported app.gamenative.data.GameSource and updated replaceSteamclientDll to call the new getAppDirPath overload with an isSteamSource boolean derived from the app ID/source.

Sequence Diagram(s)

sequenceDiagram
    participant SteamUtils as SteamUtils (caller)
    participant SteamService as SteamService
    participant Pref as PrefManager / FS

    SteamUtils->>SteamService: getAppDirPath(appId, isSteamSource)
    alt legacy internal exists
        SteamService->>Pref: checkInternalPath(appId, legacyNames)
        Pref-->>SteamService: internalPath (exists)
        SteamService-->>SteamUtils: return internalPath
    else check external when steamApp true
        SteamService->>Pref: checkExternalPath(appId)
        Pref-->>SteamService: externalPath (exists?)
        alt external exists
            SteamService-->>SteamUtils: return externalPath
        else fallback based on Pref.useExternalStorage
            SteamService->>Pref: read useExternalStorage
            Pref-->>SteamService: useExternalStorage (true/false)
            alt true
                SteamService-->>SteamUtils: return externalDefault
            else
                SteamService-->>SteamUtils: return internalPathFallback
            end
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped through folders, sniffed each trail,
A flag at my paw set a new tale,
Internal whispers, external calls,
I chose the burrow where the game now sprawls,
Hooray—storage hops and never fails! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is partially related to the changeset—it mentions adding a check for steam apps and forcing internal paths for steam client, which aligns with the main objective, but it is incomplete and cut off mid-sentence, making it unclear and somewhat vague about the full scope of changes. Complete the title to be a full, clear sentence that captures the main change. For example: 'Add steamApp flag to getAppDirPath to force internal path for steam client DLL' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@jks211
Copy link
Author

jks211 commented Feb 5, 2026

Screenshot 2026-02-04 221922 Screenshot 2026-02-04 222937 Screenshot 2026-02-04 222545

Copy link
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 2 files

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@app/src/main/java/app/gamenative/utils/SteamUtils.kt`:
- Around line 230-233: The contains-based source check is fragile; use
ContainerUtils.extractGameSourceFromContainerId(appId) instead of
appId.contains("${GameSource.STEAM.name}") in replaceSteamclientDll so the
source is derived via prefix matching. Keep steamAppId as
ContainerUtils.extractGameIdFromContainerId(appId), call
ContainerUtils.extractGameSourceFromContainerId(appId) to get the source value,
and pass that result into SteamService.getAppDirPath(steamAppId, <source>)
rather than the boolean contains expression.

@jks211
Copy link
Author

jks211 commented Feb 5, 2026

I realize that probably overloading this utils function isn't good architectural hygiene, I was going for a quicker fix to avoid refactoring but if there is a less invasive way of doing it properly let me know.

Comment on lines 739 to 763
fun getAppDirPath(gameId: Int, steamApp: Boolean): String {

val info = getAppInfoOf(gameId)
val appName = getAppDirName(info)
val oldName = info?.name.orEmpty()

// Internal first (legacy installs), external second
val internalPath = Paths.get(internalAppInstallPath, appName)
if (Files.exists(internalPath)) return internalPath.pathString
val internalOld = Paths.get(internalAppInstallPath, oldName)
if (oldName.isNotEmpty() && Files.exists(internalOld)) return internalOld.pathString

val externalPath = Paths.get(externalAppInstallPath, appName)
val externalOld = Paths.get(externalAppInstallPath, oldName)
if (steamApp) {
if (Files.exists(externalPath)) return externalPath.pathString
if (oldName.isNotEmpty() && Files.exists(externalOld)) return externalOld.pathString
}

// Nothing on disk yet – default to whatever location you want new installs to use
if (PrefManager.useExternalStorage && steamApp) {
return externalPath.pathString
}
return internalPath.pathString
}
Copy link
Owner

Choose a reason for hiding this comment

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

Is this a copy of the getAppDirPath method, with an extra param?

            if (steamApp) {
                if (Files.exists(externalPath)) return externalPath.pathString
                if (oldName.isNotEmpty() && Files.exists(externalOld)) return externalOld.pathString
            }

I see only that changed. Why only if it's a steam app?

Copy link
Author

Choose a reason for hiding this comment

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

I had to really dive deeper to make sure this was the "simplest fix". There is a sequence of backing up steam client dlls and restoring them for each game that launches. It happens regardless if the game is EPIC, GOG, Steam, etc.

I didn't want to just assume we can skip this backup/restore step altogether, I would suspect that the maybe the steam client can be used for steaminput even in non steam games and/or for other future features.

Take a look at launchApp in MainViewModel.kt (line 250).

The other option is we give a bogus name for the the variable appName, and thus the rootdirectory for the recursive search (the variable appName is an empty string in cases of non steam games). That way the recursive search for a steam client fails immediately... that didn't sit right for me as a fix either.

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.

3 participants