Fix favorites sync and backup/restore crashing on older devices
This commit is contained in:
parent
b06f253f83
commit
895191814e
@ -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) }
|
||||
|
@ -249,6 +249,7 @@ class EHentaiUpdateWorker: JobService(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
companion object {
|
||||
private const val MAX_UPDATE_FAILURES = 5
|
||||
|
||||
|
@ -2,6 +2,7 @@ package exh.favorites
|
||||
|
||||
import android.content.Context
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import com.elvishew.xlog.XLog
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -114,7 +115,9 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
}
|
||||
|
||||
// Do not update galleries while syncing favorites
|
||||
EHentaiUpdateWorker.cancelBackground(context)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
EHentaiUpdateWorker.cancelBackground(context)
|
||||
}
|
||||
|
||||
storage.getRealm().use { realm ->
|
||||
realm.trans {
|
||||
@ -167,7 +170,9 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
}
|
||||
|
||||
// Update galleries again!
|
||||
EHentaiUpdateWorker.scheduleBackground(context)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
EHentaiUpdateWorker.scheduleBackground(context)
|
||||
}
|
||||
}
|
||||
|
||||
if(errorList.isEmpty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user