From 1090c04fe33cbefb3c0965c6df5da8029f4c3438 Mon Sep 17 00:00:00 2001 From: len Date: Mon, 18 Jul 2016 21:01:51 +0200 Subject: [PATCH] Remove deprecated calls and fix a potential race condition --- .../kanade/tachiyomi/data/database/DbExtensions.kt | 12 ++++++------ .../database/resolvers/ChapterProgressPutResolver.kt | 2 +- .../resolvers/ChapterSourceOrderPutResolver.kt | 2 +- .../database/resolvers/HistoryLastReadPutResolver.kt | 4 ++-- .../data/database/resolvers/MangaFlagsPutResolver.kt | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbExtensions.kt index 9c60968a8..252ac0829 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbExtensions.kt @@ -3,23 +3,23 @@ package eu.kanade.tachiyomi.data.database import com.pushtorefresh.storio.sqlite.StorIOSQLite inline fun StorIOSQLite.inTransaction(block: () -> Unit) { - internal().beginTransaction() + lowLevel().beginTransaction() try { block() - internal().setTransactionSuccessful() + lowLevel().setTransactionSuccessful() } finally { - internal().endTransaction() + lowLevel().endTransaction() } } inline fun StorIOSQLite.inTransactionReturn(block: () -> T): T { - internal().beginTransaction() + lowLevel().beginTransaction() try { val result = block() - internal().setTransactionSuccessful() + lowLevel().setTransactionSuccessful() return result } finally { - internal().endTransaction() + lowLevel().endTransaction() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt index f7fb67084..a272597b5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterProgressPutResolver.kt @@ -15,7 +15,7 @@ class ChapterProgressPutResolver : PutResolver() { val updateQuery = mapToUpdateQuery(chapter) val contentValues = mapToContentValues(chapter) - val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) + val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt index 04d7ac275..77bc0afad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/ChapterSourceOrderPutResolver.kt @@ -15,7 +15,7 @@ class ChapterSourceOrderPutResolver : PutResolver() { val updateQuery = mapToUpdateQuery(chapter) val contentValues = mapToContentValues(chapter) - val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) + val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt index 4d2146321..4adc3d2e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/HistoryLastReadPutResolver.kt @@ -21,11 +21,11 @@ class HistoryLastReadPutResolver : PutResolver() { val contentValues = mapToContentValues(history) // Execute query - val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) + val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues) // If chapter not found in history insert into database if (numberOfRowsUpdated == 0) { - db.put().`object`(history).prepare().asRxObservable().subscribe() + db.put().`object`(history).prepare().executeAsBlocking() } // Update result PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt index f9cc403ea..0c9b28c52 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaFlagsPutResolver.kt @@ -15,7 +15,7 @@ class MangaFlagsPutResolver : PutResolver() { val updateQuery = mapToUpdateQuery(manga) val contentValues = mapToContentValues(manga) - val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) + val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) }