Loading app/src/main/java/foundation/e/apps/data/install/workmanager/InstallOrchestrator.kt +19 −33 Original line number Diff line number Diff line Loading @@ -49,11 +49,7 @@ class InstallOrchestrator @Inject constructor( runCatching { cancelFailedDownloads() }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> Timber.e(throwable, "Failed to reconcile startup downloads") else -> throw throwable } handleFailure(throwable, "Failed to reconcile startup downloads") } observeDownloads() } Loading @@ -67,14 +63,18 @@ class InstallOrchestrator @Inject constructor( ?.let { queuedDownload -> trigger(queuedDownload) } } }.onFailure { throwable -> handleFailure(throwable, "Failed to enqueue download worker") } }.launchIn(scope) } private fun handleFailure(throwable: Throwable, errorMessage: String) { when (throwable) { is CancellationException -> throw throwable is Exception -> Timber.e(throwable, "Failed to enqueue download worker") is Exception -> Timber.e(throwable, errorMessage) else -> throw throwable } } }.launchIn(scope) } private suspend fun trigger(download: AppInstall) { val uniqueWorkName = InstallWorkManager.getUniqueWorkName(download.packageName) Loading @@ -84,19 +84,12 @@ class InstallOrchestrator @Inject constructor( operation.await() Timber.d("INSTALL: Successfully enqueued unique work for ${download.name}: $uniqueWorkName") }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> { Timber.e( handleFailure( throwable, "INSTALL: Failed to enqueue unique work for ${download.name}: $uniqueWorkName" ) appManagerWrapper.installationIssue(download) } else -> throw throwable } } } private suspend fun cancelFailedDownloads() { Loading Loading @@ -136,18 +129,11 @@ class InstallOrchestrator @Inject constructor( } } }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> { Timber.e( handleFailure( throwable, "INSTALL: Failed to reconcile startup state for ${app.name}/${app.packageName}" ) } else -> throw throwable } } } } Loading Loading
app/src/main/java/foundation/e/apps/data/install/workmanager/InstallOrchestrator.kt +19 −33 Original line number Diff line number Diff line Loading @@ -49,11 +49,7 @@ class InstallOrchestrator @Inject constructor( runCatching { cancelFailedDownloads() }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> Timber.e(throwable, "Failed to reconcile startup downloads") else -> throw throwable } handleFailure(throwable, "Failed to reconcile startup downloads") } observeDownloads() } Loading @@ -67,14 +63,18 @@ class InstallOrchestrator @Inject constructor( ?.let { queuedDownload -> trigger(queuedDownload) } } }.onFailure { throwable -> handleFailure(throwable, "Failed to enqueue download worker") } }.launchIn(scope) } private fun handleFailure(throwable: Throwable, errorMessage: String) { when (throwable) { is CancellationException -> throw throwable is Exception -> Timber.e(throwable, "Failed to enqueue download worker") is Exception -> Timber.e(throwable, errorMessage) else -> throw throwable } } }.launchIn(scope) } private suspend fun trigger(download: AppInstall) { val uniqueWorkName = InstallWorkManager.getUniqueWorkName(download.packageName) Loading @@ -84,19 +84,12 @@ class InstallOrchestrator @Inject constructor( operation.await() Timber.d("INSTALL: Successfully enqueued unique work for ${download.name}: $uniqueWorkName") }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> { Timber.e( handleFailure( throwable, "INSTALL: Failed to enqueue unique work for ${download.name}: $uniqueWorkName" ) appManagerWrapper.installationIssue(download) } else -> throw throwable } } } private suspend fun cancelFailedDownloads() { Loading Loading @@ -136,18 +129,11 @@ class InstallOrchestrator @Inject constructor( } } }.onFailure { throwable -> when (throwable) { is CancellationException -> throw throwable is Exception -> { Timber.e( handleFailure( throwable, "INSTALL: Failed to reconcile startup state for ${app.name}/${app.packageName}" ) } else -> throw throwable } } } } Loading