fix(cloud-save): issue with %GameInstall% being prefixed in fileList.files#489
fix(cloud-save): issue with %GameInstall% being prefixed in fileList.files#489silentrald wants to merge 2 commits intoutkarshdalal:masterfrom
Conversation
📝 WalkthroughWalkthroughAdds early-return handling in SteamAutoCloud for filenames starting with Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
cef580f to
6b6f578
Compare
There was a problem hiding this comment.
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).
6b6f578 to
55abdb2
Compare
There was a problem hiding this comment.
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.
| 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) | ||
| ) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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>
Summary by cubic
Fixes save path parsing for %GameInstall% filenames and '.' prefixes. Prevents incorrect path resolution in Auto Cloud sync.
Written for commit e23b7dd. Summary will update on new commits.
Summary by CodeRabbit