From 5c06ec5e0bcca67913aff95339836d8c50221b3e Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Mon, 15 Sep 2025 20:36:30 +0530 Subject: [PATCH] fix: move startInitialization to inside the doWork method (#21984) fix: android background backup Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- .../app/alextran/immich/background/BackgroundWorker.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorker.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorker.kt index b69730018b..33eb60dc82 100644 --- a/mobile/android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorker.kt +++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/background/BackgroundWorker.kt @@ -54,12 +54,6 @@ class BackgroundWorker(context: Context, params: WorkerParameters) : private var foregroundFuture: ListenableFuture? = null - init { - if (!loader.initialized()) { - loader.startInitialization(ctx) - } - } - companion object { private const val NOTIFICATION_CHANNEL_ID = "immich::background_worker::notif" private const val NOTIFICATION_ID = 100 @@ -68,6 +62,10 @@ class BackgroundWorker(context: Context, params: WorkerParameters) : override fun startWork(): ListenableFuture { Log.i(TAG, "Starting background upload worker") + if (!loader.initialized()) { + loader.startInitialization(ctx) + } + val notificationChannel = NotificationChannel( NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_ID,