From 00a8040efed2f3cacb4eefc2265815b44fb380a9 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sat, 14 Nov 2026 13:17:13 +0100 Subject: [PATCH] fix(#516): review round 12 - a watch that fails early is retried --- .../calendula/data/backup/BackupChangeJob.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/BackupChangeJob.kt b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/BackupChangeJob.kt index 74a69210..3b56b30d 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/BackupChangeJob.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/data/backup/BackupChangeJob.kt @@ -9,6 +9,7 @@ import android.content.Context import android.provider.CalendarContract import android.util.Log import dagger.hilt.android.EntryPointAccessors +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -31,14 +32,18 @@ class BackupChangeJob : JobService() { override fun onStartJob(params: JobParameters): Boolean { scope.launch { - try { + // Retried when it failed early, so the watch isn't lost; once re-armed, the retry is moot. + val failed = try { val deps = EntryPointAccessors.fromApplication(applicationContext, BackupWorker.Deps::class.java) BackupScheduler.changed(applicationContext, deps.settingsPrefs()) + false + } catch (e: CancellationException) { + throw e } catch (e: Exception) { Log.w(TAG, "Queueing a backup after a change failed", e) - } finally { - jobFinished(params, false) + true } + jobFinished(params, failed) } return true }