Skip to content

fix(cloud-save): issue with %GameInstall% being prefixed in fileList.files#489

Open
silentrald wants to merge 2 commits intoutkarshdalal:masterfrom
silentrald:fix/cloud-save-gameinstall
Open

fix(cloud-save): issue with %GameInstall% being prefixed in fileList.files#489
silentrald wants to merge 2 commits intoutkarshdalal:masterfrom
silentrald:fix/cloud-save-gameinstall

Conversation

@silentrald
Copy link

@silentrald silentrald commented Feb 4, 2026


Summary by cubic

Fixes save path parsing for %GameInstall% filenames and '.' prefixes. Prevents incorrect path resolution in Auto Cloud sync.

  • Bug Fixes
    • Handle %GameInstall% filenames by building from the GameInstall directory plus the remainder.
    • Fix prefixPath when prefix is '.' to resolve to the filename only.

Written for commit e23b7dd. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed path-resolution edge cases for files using the game-install placeholder so they now resolve to the correct location.
    • Improved handling of files with a relative/current prefix to avoid incorrect path construction.
    • Ensures downloads and cloud sync place files reliably, preventing missing or misplaced files during sync.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Adds early-return handling in SteamAutoCloud for filenames starting with %GameInstall%, resolving those to the GameInstall-prefixed path. Also changes UserFileInfo.prefixPath to return only the filename when prefix is ".", preserving existing string replacements.

Changes

Cohort / File(s) Summary
SteamAutoCloud path handling
app/src/main/java/app/gamenative/service/SteamAutoCloud.kt
Added edge-case in getFullFilePath: when filename starts with %GameInstall%, remove the prefix and construct actualFilePath by joining the mapped GameInstall path with the remainder, returning it immediately. Existing conversion and fallback logic remain for other cases.
UserFileInfo.prefixPath behavior
app/src/main/java/app/gamenative/data/UserFileInfo.kt
Changed prefixPath getter: if prefix == "." return just the filename (then apply the same string substitutions); otherwise join prefix and filename as before.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • phobos665

Poem

🐇 A filename wore a curious crown,
%GameInstall% — I nudged it down.
I peel, I join, and bounce in cheer,
A tidy path now hopping near! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing save path parsing when Steam API returns filenames prefixed with %GameInstall%, which matches the core objectives of both modified files.

✏️ 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

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.

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.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


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

<violation number="1" location="app/src/main/java/app/gamenative/service/SteamAutoCloud.kt:102">
P2: Patched prefixes can make `pathTypePairs.size` non-zero while `pathPrefixes` is empty, so `fileChangeListToUserFiles` can crash indexing `pathPrefixes` when files reference prefix 0.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


val getPathTypePairs: (AppFileChangeList) -> List<Pair<String, String>> = { fileList ->
fileList.pathPrefixes
getFileListPrefixes(fileList)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 4, 2026

Choose a reason for hiding this comment

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

P2: Patched prefixes can make pathTypePairs.size non-zero while pathPrefixes is empty, so fileChangeListToUserFiles can crash indexing pathPrefixes when files reference prefix 0.

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/SteamAutoCloud.kt, line 102:

<comment>Patched prefixes can make `pathTypePairs.size` non-zero while `pathPrefixes` is empty, so `fileChangeListToUserFiles` can crash indexing `pathPrefixes` when files reference prefix 0.</comment>

<file context>
@@ -86,8 +86,20 @@ object SteamAutoCloud {
+
         val getPathTypePairs: (AppFileChangeList) -> List<Pair<String, String>> = { fileList ->
-            fileList.pathPrefixes
+            getFileListPrefixes(fileList)
                 .map {
                     var matchResults = findPlaceholderWithin(it).map { it.value }.toList()
</file context>
Fix with Cubic

Copy link

@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/service/SteamAutoCloud.kt`:
- Around line 89-103: getFileListPrefixes can synthesize a prefix list that
diverges from appFileListChange.pathPrefixes, and downstream logic (e.g.,
getPathTypePairs and fileChangeListToUserFiles) indexes pathPrefixes using
pathTypePairs.size which can cause out-of-bounds or mis-mapping; update
getFileListPrefixes to return the real fileList.pathPrefixes unless that list is
truly absent/empty (don’t discard valid prefixes), and in
fileChangeListToUserFiles (and any code reading appFileListChange.pathPrefixes)
replace direct indexing by pathTypePairs.size with safe access (use the actual
appFileListChange.pathPrefixes.size to bound indexing, or use getOrNull/zip
semantics) so you never assume synthesized prefix length equals pathPrefixes
length and avoid throwing or mis-mapping.

@silentrald silentrald force-pushed the fix/cloud-save-gameinstall branch from cef580f to 6b6f578 Compare February 4, 2026 15:50
Copy link

@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/service/SteamAutoCloud.kt`:
- Around line 301-309: The computed actualFilePath incorrectly passes a
substring like "/foo" or "\foo" to Paths.get which is treated as absolute and
ignores prefixToPath(PathType.GameInstall.name); fix the branch that handles
file.filename.startsWith("%${PathType.GameInstall.name}%") by stripping any
leading file separators (both '/' and '\') from the substring after the
%GameInstall% marker before calling Paths.get, so
prefixToPath(PathType.GameInstall.name) is always respected (refer to
file.filename, PathType.GameInstall, prefixToPath, actualFilePath, and
getFullFilePath to locate the logic).

@silentrald silentrald force-pushed the fix/cloud-save-gameinstall branch from 6b6f578 to 55abdb2 Compare February 4, 2026 16:00
Copy link

@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/service/SteamAutoCloud.kt`:
- Around line 146-153: In getFullFilePath (the lambda assigned to
getFullFilePath) the substring extracted from file.filename when the prefix is
PathType.GameInstall can begin with '/' or '\' which makes
Paths.get(prefixToPath(...), extracted) treat it as absolute and ignore the
prefix; fix by removing any leading separators from the extracted relative path
(e.g. trim leading '/' and '\\') before passing it to Paths.get so
Paths.get(prefixToPath(PathType.GameInstall.name), relativePath) always joins
under the intended base returned by prefixToPath.

Comment on lines +146 to +153
val getFullFilePath: (AppFileInfo, AppFileChangeList) -> Path = getFullFilePath@{ file, fileList ->
if (file.filename.startsWith("%${PathType.GameInstall.name}%")) {
// Edge case if the files are not properly parsed by the Steam API Call
return@getFullFilePath Paths.get(
prefixToPath(PathType.GameInstall.name),
file.filename.substring(PathType.GameInstall.name.length + 2)
)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Strip leading separators from the extracted relative path to prevent absolute-path override.

When file.filename is %GameInstall%/foo or %GameInstall%\foo, the substring(...) yields /foo or \foo. On Unix-like systems, Paths.get(prefix, "/foo") treats /foo as an absolute path and discards the prefixToPath(...) base, potentially resolving files outside the intended game install directory.

🔧 Proposed fix
         if (file.filename.startsWith("%${PathType.GameInstall.name}%")) {
             // Edge case if the files are not properly parsed by the Steam API Call
+            val relative = file.filename
+                .substring(PathType.GameInstall.name.length + 2)
+                .trimStart('/', '\\')
             return@getFullFilePath Paths.get(
                 prefixToPath(PathType.GameInstall.name),
-                file.filename.substring(PathType.GameInstall.name.length + 2)
+                relative
             )
         }
🤖 Prompt for AI Agents
In `@app/src/main/java/app/gamenative/service/SteamAutoCloud.kt` around lines 146
- 153, In getFullFilePath (the lambda assigned to getFullFilePath) the substring
extracted from file.filename when the prefix is PathType.GameInstall can begin
with '/' or '\' which makes Paths.get(prefixToPath(...), extracted) treat it as
absolute and ignore the prefix; fix by removing any leading separators from the
extracted relative path (e.g. trim leading '/' and '\\') before passing it to
Paths.get so Paths.get(prefixToPath(PathType.GameInstall.name), relativePath)
always joins under the intended base returned by prefixToPath.

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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="app/src/main/java/app/gamenative/data/UserFileInfo.kt">

<violation number="1" location="app/src/main/java/app/gamenative/data/UserFileInfo.kt:30">
P2: The new `prefix == "."` check is unreachable because `prefix` always contains `%${root.name}%`, so this change doesn't alter behavior and the `%GameInstall%` prefix issue remains unfixed.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

val prefixPath: String
get() = Paths.get(prefix, filename).pathString
get() = (
if (prefix == ".") Paths.get(filename)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 6, 2026

Choose a reason for hiding this comment

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

P2: The new prefix == "." check is unreachable because prefix always contains %${root.name}%, so this change doesn't alter behavior and the %GameInstall% prefix issue remains unfixed.

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/data/UserFileInfo.kt, line 30:

<comment>The new `prefix == "."` check is unreachable because `prefix` always contains `%${root.name}%`, so this change doesn't alter behavior and the `%GameInstall%` prefix issue remains unfixed.</comment>

<file context>
@@ -26,7 +26,11 @@ data class UserFileInfo(
     val prefixPath: String
-        get() = Paths.get(prefix, filename).pathString
+        get() = (
+                if (prefix == ".") Paths.get(filename)
+                else Paths.get(prefix, filename)
+            )
</file context>
Fix with Cubic

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.

1 participant