Fix WorkManager cancellation issues

(cherry picked from commit 7e6811692e8c16a074271ffb1ca01a73daeb4404)
This commit is contained in:
Jobobby04 2024-06-01 17:46:42 -04:00 committed by Cuong M. Tran
parent d67223751b
commit d1671457e9
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
2 changed files with 3 additions and 3 deletions

View file

@ -45,7 +45,7 @@ class SyncDataJob(private val context: Context, workerParams: WorkerParameters)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
notifier.showSyncError(e.message)
Result.failure()
Result.success() // try again next time
} finally {
context.cancelNotification(Notifications.ID_RESTORE_PROGRESS)
}

View file

@ -61,14 +61,14 @@ class EHentaiUpdateWorker(private val context: Context, workerParams: WorkerPara
override suspend fun doWork(): Result {
return try {
if (requiresWifiConnection(preferences) && !context.isConnectedToWifi()) {
Result.failure()
Result.success() // retry again later
} else {
startUpdating()
logger.d("Update job completed!")
Result.success()
}
} catch (e: Exception) {
Result.failure()
Result.success() // retry again later
}
}