Fix favorites sync and backup/restore crashing on older devices

This commit is contained in:
NerdNumber9
2019-04-20 14:01:18 -04:00
parent b06f253f83
commit 895191814e
3 changed files with 15 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import android.app.Service
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import com.elvishew.xlog.XLog
@@ -180,13 +181,17 @@ class BackupRestoreService : Service() {
subscription = Observable.using(
{
// Pause auto-gallery-update during restore
EHentaiUpdateWorker.cancelBackground(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
EHentaiUpdateWorker.cancelBackground(this)
}
db.lowLevel().beginTransaction()
},
{ getRestoreObservable(uri).doOnNext { db.lowLevel().setTransactionSuccessful() } },
{
// Resume auto-gallery-update
EHentaiUpdateWorker.scheduleBackground(this)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
EHentaiUpdateWorker.scheduleBackground(this)
}
executor.execute { db.lowLevel().endTransaction() }
})
.doAfterTerminate { stopSelf(startId) }