Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/src/main/java/app/gamenative/service/SteamService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,15 @@ class SteamService : Service(), IChallengeUrlChanged {
Timber.i("Resumed download: initialized with $persistedBytes bytes")
}

// register BEFORE launching: a fast verify/update on up-to-date data can
// complete the launch body synchronously (DepotDownloader has no chunks to
// fetch). removeDownloadJob inside that body must find the entry to emit
// DownloadStatusChanged(false); otherwise the UI hangs at 0% and the next
// downloadApp call returns the stale DownloadInfo from the still-populated
// map (line ~1666 short-circuit).
downloadJobs[appId] = di
notifyDownloadStarted(appId)

val downloadJob = instance!!.scope.launch {
try {
// Get licenses from database
Expand Down Expand Up @@ -2034,16 +2043,18 @@ class SteamService : Service(), IChallengeUrlChanged {
}
}
downloadJob.invokeOnCompletion { throwable ->
// safety net for paths the inline removeDownloadJob doesn't cover:
// early `return@launch` on empty licenses, exceptions before the catch
// handlers, and cancellations thrown out of suspension points.
// second call is a no-op if the inline path already removed the entry.
removeDownloadJob(appId)
if (throwable is kotlinx.coroutines.CancellationException) {
Timber.d(throwable, "Download canceled for app $appId")
removeDownloadJob(appId)
}
}
di.setDownloadJob(downloadJob)
}

downloadJobs[appId] = info
notifyDownloadStarted(appId)
return info
}

Expand Down
Loading