Consider individual manga as transactions rather than entire restore job (closes #2482)

This commit is contained in:
arkon
2020-04-25 16:39:00 -04:00
parent 0f48563e29
commit 96c55db7ca
5 changed files with 154 additions and 167 deletions

View File

@@ -88,7 +88,7 @@ class SettingsBackupController : SettingsController() {
summaryRes = R.string.pref_restore_backup_summ
onClick {
if (!isRestoreStarted) {
if (!BackupRestoreService.isRunning(context)) {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "application/*"
@@ -277,7 +277,6 @@ class SettingsBackupController : SettingsController() {
val context = applicationContext
if (context != null) {
BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
isRestoreStarted = true
}
}
}
@@ -303,8 +302,6 @@ class SettingsBackupController : SettingsController() {
notifier.showBackupError(intent.getStringExtra(BackupConst.EXTRA_ERROR_MESSAGE))
}
BackupConst.ACTION_RESTORE_COMPLETED -> {
isRestoreStarted = false
val time = intent.getLongExtra(BackupConst.EXTRA_TIME, 0)
val errorCount = intent.getIntExtra(BackupConst.EXTRA_ERRORS, 0)
val path = intent.getStringExtra(BackupConst.EXTRA_ERROR_FILE_PATH)
@@ -312,8 +309,6 @@ class SettingsBackupController : SettingsController() {
notifier.showRestoreComplete(time, errorCount, path, file)
}
BackupConst.ACTION_RESTORE_ERROR -> {
isRestoreStarted = false
notifier.showRestoreError(intent.getStringExtra(BackupConst.EXTRA_ERROR_MESSAGE))
}
}
@@ -326,6 +321,5 @@ class SettingsBackupController : SettingsController() {
const val CODE_BACKUP_DIR = 503
var isBackupStarted = false
var isRestoreStarted = false
}
}

View File

@@ -31,6 +31,7 @@ internal class BackupNotifier(private val context: Context) {
setContentText(context.getString(R.string.creating_backup))
setProgress(0, 0, true)
setOngoing(true)
}
notificationBuilder.show(Notifications.ID_BACKUP)
@@ -43,6 +44,7 @@ internal class BackupNotifier(private val context: Context) {
// Remove progress bar
setProgress(0, 0, false)
setOngoing(false)
}
notificationBuilder.show(Notifications.ID_BACKUP)
@@ -58,6 +60,7 @@ internal class BackupNotifier(private val context: Context) {
// Remove progress bar
setProgress(0, 0, false)
setOngoing(false)
// Clear old actions if they exist
if (mActions.isNotEmpty()) {
@@ -80,6 +83,7 @@ internal class BackupNotifier(private val context: Context) {
setContentText(content)
setProgress(maxAmount, progress, false)
setOngoing(true)
// Clear old actions if they exist
if (mActions.isNotEmpty()) {
@@ -105,6 +109,7 @@ internal class BackupNotifier(private val context: Context) {
// Remove progress bar
setProgress(0, 0, false)
setOngoing(false)
}
notificationBuilder.show(Notifications.ID_RESTORE)
@@ -128,6 +133,7 @@ internal class BackupNotifier(private val context: Context) {
// Remove progress bar
setProgress(0, 0, false)
setOngoing(false)
// Clear old actions if they exist
if (mActions.isNotEmpty()) {