From e4ea5d03444255237ecde4be7c0bbbac5ca108c2 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 12 May 2020 09:11:52 -0400 Subject: [PATCH] Don't throw exception to stop restore job --- .../kanade/tachiyomi/data/backup/BackupRestoreService.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt index 59ca6316ed..e2f15efce0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt @@ -175,7 +175,9 @@ class BackupRestoreService : Service() { stopSelf(startId) } job = GlobalScope.launch(handler) { - restoreBackup(uri) + if (!restoreBackup(uri)) { + notifier.showRestoreError(getString(R.string.restoring_backup_canceled)) + } } job?.invokeOnCompletion { stopSelf(startId) @@ -189,7 +191,7 @@ class BackupRestoreService : Service() { * * @param uri backup file to restore */ - private fun restoreBackup(uri: Uri) { + private fun restoreBackup(uri: Uri): Boolean { val startTime = System.currentTimeMillis() val reader = JsonReader(contentResolver.openInputStream(uri)!!.bufferedReader()) @@ -213,7 +215,7 @@ class BackupRestoreService : Service() { // Restore individual manga mangasJson.forEach { if (job?.isActive != true) { - throw Exception(getString(R.string.restoring_backup_canceled)) + return false } restoreManga(it.asJsonObject) @@ -225,6 +227,7 @@ class BackupRestoreService : Service() { val logFile = writeErrorLog() notifier.showRestoreComplete(time, errors.size, logFile.parent, logFile.name) + return true } private fun restoreCategories(categoriesJson: JsonElement) {