fix: don't let expired free weekend licenses shadow owned games#1148
fix: don't let expired free weekend licenses shadow owned games#1148kiequoo wants to merge 4 commits intoutkarshdalal:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughRemoved a local SQLITE_MAX_VARS constant and introduced a shared Changes
Sequence Diagram(s)sequenceDiagram
participant PICS as PICS Callback
participant SteamSvc as SteamService
participant DB as Database (DAOs)
PICS->>SteamSvc: package callback (packageId, apps, depots)
SteamSvc->>DB: batch load apps for package appIds
SteamSvc->>DB: batch load licenses for packageIds
SteamSvc->>SteamSvc: selectPreferredPackageId(existingPkg, incomingPkg, licensesByPackage)
SteamSvc->>DB: update or insert SteamApp rows (conditionally using selected packageId)
SteamSvc->>DB: enqueue processed app IDs
DB-->>SteamSvc: ack
SteamSvc-->>PICS: processing complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/src/main/java/app/gamenative/service/SteamService.kt`:
- Around line 3849-3866: The current update logic only skips updating when the
incoming package is expired, which still allows a temporary free-weekend package
to overwrite a valid purchased package; instead compute a stable precedence
between the existing SteamApp.packageId and the incoming pkg.id before calling
appDao.update: use licenseDao.getExpiredPackageIds() plus whatever
expiry/start/purchase metadata is available on picsCallback.packages[pkg.id] (or
a lookup via licenseDao) to determine which package is higher-priority (e.g.,
prefer non-expired over expired; if both non-expired prefer the package with the
later expiry or explicit purchase timestamp; if tied use deterministic
tie-breaker like package id), and only call
appDao.update(steamApp.copy(packageId = selectedPkgId)) when selectedPkgId !=
steamApp.packageId; reference picsCallback.packages,
licenseDao.getExpiredPackageIds(), appDao.findApp(), appDao.update(), and
SteamApp.packageId when making the change.
🪄 Autofix (Beta)
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
Run ID: 313034e5-f5a4-43fa-ab24-30021b59dfd0
📒 Files selected for processing (2)
app/src/main/java/app/gamenative/db/dao/SteamLicenseDao.ktapp/src/main/java/app/gamenative/service/SteamService.kt
When a user played a free weekend and later purchased the game, both packages contain the same app ID. PICS processing was overwriting package_id unconditionally, so whichever package was processed last won — if the expired free weekend package landed last, the owned-apps query excluded the game because it only checked that one package_id. Pre-load expired package IDs once per PICS transaction batch and skip updating package_id when the incoming package is expired but the stored one is already valid.
Adds two tests to SteamPackageSelectionTest verifying that a game whose only license is AutoGrant (package 0) still gets its packageId set, and that a durable paid purchase correctly outranks AutoGrant when both are present.
Removes the coupling where SteamAppDao depended on a constant defined in SteamLicenseDao's file.
7c4b197 to
40f2e0b
Compare
Summary
I played Dying Light during a Steam free weekend, then later bought it. After purchasing, the game wasn't showing up in GameNative's library at all.
This is related to but distinct from the expired-license filtering work in #945, #982, and #985. Those PRs addressed expired free weekend games appearing in the library. This fixes the inverse: a game you genuinely own disappearing because the expired free weekend license shadows the real purchase.
Root cause: During PICS package processing, each package unconditionally overwrites the
packageIdon its associatedSteamApprows. If the expired free weekend package happened to be processed after the real purchase package, it clobberedpackageIdwith the expired license's ID — making the game invisible to the owned apps query (which, post-#985, correctly filters out expired packages).Fix: Before iterating packages, load the set of all expired package IDs. When updating an app's
packageId, skip the write if the incoming package is expired but the app's currentpackageIdis not — a real purchase already won, don't let an expired license shadow it.SteamLicenseDao: new query to fetch expired package IDs (license_flags & 8 != 0)SteamService: guard aroundpackageIdupdate — expired packages can only overwrite other expired packagesSummary by cubic
Fixes cases where expired or temporary Steam licenses could hide games you own. PICS updates now choose a stable
packageIdso durable purchases and free-to-play titles remain visible.AutoGranthandling and package-ID tie-breaks to stop temporary/expired licenses from overwriting purchases.SQLITE_MAX_VARSto pick the best package per app and avoid overwrite-order issues.Written for commit 40f2e0b. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
New Features
Tests