DownloadWorkerUtil: Cancel download regardless of status when requested
This is useful when an active download is stuck which could happen if the app was force stopped by user or killed by Android. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -84,8 +84,8 @@ class DownloadWorkerUtil @Inject constructor(
|
||||
Log.i(TAG, "Cancelling download for $packageName")
|
||||
WorkManager.getInstance(context).cancelAllWorkByTag("$PACKAGE_NAME:$packageName")
|
||||
downloadsList.filter { it.isNotEmpty() }.firstOrNull()
|
||||
?.find { it.packageName == packageName && it.downloadStatus == DownloadStatus.QUEUED }
|
||||
?.let { downloadDao.update(it.copy(downloadStatus = DownloadStatus.CANCELLED)) }
|
||||
?.find { it.packageName == packageName }
|
||||
?.let { downloadDao.updateStatus(packageName, DownloadStatus.CANCELLED) }
|
||||
}
|
||||
|
||||
suspend fun clearDownload(packageName: String, versionCode: Int) {
|
||||
|
||||
Reference in New Issue
Block a user