diff --git a/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt b/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt index a9b06a9f6..65dea2763 100644 --- a/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt +++ b/app/src/main/java/com/aurora/store/data/work/DownloadWorker.kt @@ -183,10 +183,13 @@ class DownloadWorker @AssistedInject constructor( if (isStopped) return onFailure(Exceptions.DownloadFailedException()) // Verify downloaded files - val verifySuccess = verifyFiles(download.packageName, files) - - // Report failure if verification failed - if (!verifySuccess || isStopped) return onFailure(Exceptions.VerificationFailedException()) + try { + notifyStatus(DownloadStatus.VERIFYING) + files.forEach { file -> require(verifyFile(file)) } + } catch (exception: Exception) { + Log.e(TAG, "Failed to verify ${download.packageName}", exception) + onFailure(Exceptions.VerificationFailedException()) + } Log.i(TAG, "Finished downloading & verifying ${download.packageName}") notifyStatus(DownloadStatus.COMPLETED) @@ -194,24 +197,6 @@ class DownloadWorker @AssistedInject constructor( return onSuccess() } - private suspend fun verifyFiles( - packageName: String, - files: List - ): Boolean = withContext(NonCancellable) { - notifyStatus(DownloadStatus.VERIFYING) - - for (file in files) { - try { - verifyFile(file) - } catch (e: Exception) { - Log.e(TAG, "Failed to verify $packageName : ${file.name}", e) - return@withContext false - } - } - - true - } - private suspend fun onSuccess(): Result = withContext(NonCancellable) { return@withContext try { appInstaller.getPreferredInstaller().install(download)