fix: Cap Steam DL size to installSize to avoid gigantic dl size reporting.#1482
Conversation
📝 WalkthroughWalkthroughThe PR adds validation to ChangesDownload Size Validation
Possibly related PRs
Suggested reviewers
Poem
🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/utils/SteamUtils.kt (1)
94-95: ⚡ Quick winConsider validating
manifest.sizebefore using it as the fallback.While the current fix correctly addresses the reported bug (oversized
manifest.download), the fallback tomanifest.sizeassumes that value is itself valid. If both fields are corrupted, the function could still return an invalid size.🛡️ Proposed additional validation
// Cap DownloadSize to installSize due to incorrectly gigantic sizes - // DL size should always be smaller than installSize. + // DL size should not be larger than installSize. val hasSaneDownload = manifest.download > 0L && manifest.download <= manifest.size - return if (hasSaneDownload) manifest.download else manifest.size + val hasSaneSize = manifest.size > 0L + return when { + hasSaneDownload -> manifest.download + hasSaneSize -> manifest.size + else -> 0L + } }Note: The downstream caller already applies
.coerceAtLeast(1L), so returning0Lfor completely invalid data would be safely handled.🤖 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/utils/SteamUtils.kt` around lines 94 - 95, The current logic uses manifest.size as an unconditional fallback when manifest.download is invalid (hasSaneDownload), but manifest.size may also be corrupted; add a second validation (e.g., hasSaneSize) that ensures manifest.size > 0 and >= manifest.download lower bound before returning it, and if both are invalid return 0L (the caller will coerce to at least 1L). Update the code that currently defines hasSaneDownload and the subsequent return to check manifest.size as well (referencing manifest.download, manifest.size and hasSaneDownload) and return 0L when neither value is valid.
🤖 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.
Nitpick comments:
In `@app/src/main/java/app/gamenative/utils/SteamUtils.kt`:
- Around line 94-95: The current logic uses manifest.size as an unconditional
fallback when manifest.download is invalid (hasSaneDownload), but manifest.size
may also be corrupted; add a second validation (e.g., hasSaneSize) that ensures
manifest.size > 0 and >= manifest.download lower bound before returning it, and
if both are invalid return 0L (the caller will coerce to at least 1L). Update
the code that currently defines hasSaneDownload and the subsequent return to
check manifest.size as well (referencing manifest.download, manifest.size and
hasSaneDownload) and return 0L when neither value is valid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a522d926-5f73-47e0-88e8-fbd04731589f
📒 Files selected for processing (1)
app/src/main/java/app/gamenative/utils/SteamUtils.kt
Description
Cap the Steam App's DL size to installSize if it's larger than InstallSize.
This helps alleviate and issue where the DL size is incorrectly reported and showing gigantic sizes instead.
It looks like it's hard to figure out this edge-case, so it's best for now to cap it and we can investigate in more detail later.
Recording
Before:

After:

Type of Change
Checklist
#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.CONTRIBUTING.md.Summary by cubic
Cap Steam download size to the install size when the reported download is invalid or larger than install size. This fixes cases where the app showed gigantic download sizes due to bad manifest data.
Written for commit 95d728c. Summary will update on new commits. Review in cubic
Summary by CodeRabbit