Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,23 @@ class SyncMediaWorker(
monitorProgress(backend)
}
} catch (cancellationException: CancellationException) {
Timber.w(cancellationException)
Timber.w(cancellationException, "SyncMediaWorker cancelled (user tapped Cancel or WorkManager cancelled)")
notificationManager?.cancel(NotificationId.SYNC_MEDIA)
Timber.d("SyncMediaWorker: progress notification cancelled after worker cancellation")
cancelMediaSync(CollectionManager.getBackend())
throw cancellationException
} catch (throwable: Throwable) {
Timber.w(throwable)
Timber.w(throwable, "SyncMediaWorker failed")
notify {
setContentTitle(CollectionManager.TR.syncMediaFailed())
throwable.localizedMessage?.let { message ->
setContentText(message)
}
}
Timber.d("SyncMediaWorker: showing failure notification")
return Result.failure()
}
Timber.d("SyncMediaWorker: cancelling notification")
Timber.d("SyncMediaWorker: cancelling progress notification (sync completed)")
notificationManager?.cancel(NotificationId.SYNC_MEDIA)

Timber.d("SyncMediaWorker: success")
Expand Down
8 changes: 6 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/worker/SyncWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,23 @@ class SyncWorker(
try {
syncCollection(auth, shouldSyncMedia)
} catch (cancellationException: CancellationException) {
Timber.w(cancellationException, "SyncWorker cancelled (user tapped Cancel or WorkManager cancelled)")
notificationManager?.cancel(NotificationId.SYNC)
Timber.d("SyncWorker: progress notification cancelled after worker cancellation")
cancelSync(CollectionManager.getBackend())
throw cancellationException
} catch (throwable: Throwable) {
Timber.w(throwable)
Timber.w(throwable, "SyncWorker failed")
notify {
setContentTitle(applicationContext.getString(R.string.sync_error))
throwable.localizedMessage?.let { message ->
setContentText(message)
}
}
Timber.d("SyncWorker: showing failure notification")
return Result.failure()
}
Timber.d("SyncWorker: cancelling notification")
Timber.d("SyncWorker: cancelling progress notification (sync completed)")
notificationManager?.cancel(NotificationId.SYNC)

Timber.d("SyncWorker: success")
Expand Down
Loading