mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 02:18:24 +01:00
Remove deprecated calls and fix a potential race condition
This commit is contained in:
parent
33b04427d5
commit
1090c04fe3
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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())
|
||||||
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user