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
inline fun StorIOSQLite.inTransaction(block: () -> Unit) {
internal().beginTransaction()
lowLevel().beginTransaction()
try {
block()
internal().setTransactionSuccessful()
lowLevel().setTransactionSuccessful()
} finally {
internal().endTransaction()
lowLevel().endTransaction()
}
}
inline fun <T> StorIOSQLite.inTransactionReturn(block: () -> T): T {
internal().beginTransaction()
lowLevel().beginTransaction()
try {
val result = block()
internal().setTransactionSuccessful()
lowLevel().setTransactionSuccessful()
return result
} finally {
internal().endTransaction()
lowLevel().endTransaction()
}
}

View File

@ -15,7 +15,7 @@ class ChapterProgressPutResolver : PutResolver<Chapter>() {
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())
}

View File

@ -15,7 +15,7 @@ class ChapterSourceOrderPutResolver : PutResolver<Chapter>() {
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())
}

View File

@ -21,11 +21,11 @@ class HistoryLastReadPutResolver : PutResolver<History>() {
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())

View File

@ -15,7 +15,7 @@ class MangaFlagsPutResolver : PutResolver<Manga>() {
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())
}