Remove deprecated calls and fix a potential race condition

This commit is contained in:
len 2016-07-18 21:01:51 +02:00
parent 33b04427d5
commit 1090c04fe3
5 changed files with 11 additions and 11 deletions

View File

@ -3,23 +3,23 @@ package eu.kanade.tachiyomi.data.database
import com.pushtorefresh.storio.sqlite.StorIOSQLite import com.pushtorefresh.storio.sqlite.StorIOSQLite
inline fun StorIOSQLite.inTransaction(block: () -> Unit) { inline fun StorIOSQLite.inTransaction(block: () -> Unit) {
internal().beginTransaction() lowLevel().beginTransaction()
try { try {
block() block()
internal().setTransactionSuccessful() lowLevel().setTransactionSuccessful()
} finally { } finally {
internal().endTransaction() lowLevel().endTransaction()
} }
} }
inline fun <T> StorIOSQLite.inTransactionReturn(block: () -> T): T { inline fun <T> StorIOSQLite.inTransactionReturn(block: () -> T): T {
internal().beginTransaction() lowLevel().beginTransaction()
try { try {
val result = block() val result = block()
internal().setTransactionSuccessful() lowLevel().setTransactionSuccessful()
return result return result
} finally { } finally {
internal().endTransaction() lowLevel().endTransaction()
} }
} }

View File

@ -15,7 +15,7 @@ class ChapterProgressPutResolver : PutResolver<Chapter>() {
val updateQuery = mapToUpdateQuery(chapter) val updateQuery = mapToUpdateQuery(chapter)
val contentValues = mapToContentValues(chapter) val contentValues = mapToContentValues(chapter)
val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
} }

View File

@ -15,7 +15,7 @@ class ChapterSourceOrderPutResolver : PutResolver<Chapter>() {
val updateQuery = mapToUpdateQuery(chapter) val updateQuery = mapToUpdateQuery(chapter)
val contentValues = mapToContentValues(chapter) val contentValues = mapToContentValues(chapter)
val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
} }

View File

@ -21,11 +21,11 @@ class HistoryLastReadPutResolver : PutResolver<History>() {
val contentValues = mapToContentValues(history) val contentValues = mapToContentValues(history)
// Execute query // 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 chapter not found in history insert into database
if (numberOfRowsUpdated == 0) { if (numberOfRowsUpdated == 0) {
db.put().`object`(history).prepare().asRxObservable().subscribe() db.put().`object`(history).prepare().executeAsBlocking()
} }
// Update result // Update result
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())

View File

@ -15,7 +15,7 @@ class MangaFlagsPutResolver : PutResolver<Manga>() {
val updateQuery = mapToUpdateQuery(manga) val updateQuery = mapToUpdateQuery(manga)
val contentValues = mapToContentValues(manga) val contentValues = mapToContentValues(manga)
val numberOfRowsUpdated = db.internal().update(updateQuery, contentValues) val numberOfRowsUpdated = db.lowLevel().update(updateQuery, contentValues)
PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table()) PutResult.newUpdateResult(numberOfRowsUpdated, updateQuery.table())
} }