Do db migration, make DownloadLabel nonnull
This commit is contained in:
1 parent
975421044c
commit
1120c23709
5 files changed
+462
-12
No files matched your search
@@ -109,9 +109,7 @@ object EhDB {
|
||||
@Synchronized
|
||||
fun addDownloadLabel(label: String): DownloadLabel {
|
||||
val dao = db.downloadLabelDao()
|
||||
val raw = DownloadLabel()
|
||||
raw.label = label
|
||||
raw.time = System.currentTimeMillis()
|
||||
val raw = DownloadLabel(label, System.currentTimeMillis())
|
||||
raw.id = dao.insert(raw)
|
||||
return raw
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class ThumbKeyMigration : AutoMigrationSpec {
|
||||
|
||||
@Database(
|
||||
entities = [DownloadInfo::class, DownloadLabel::class, DownloadDirname::class, Filter::class, HistoryInfo::class, LocalFavoriteInfo::class, QuickSearch::class],
|
||||
version = 8,
|
||||
version = 9,
|
||||
exportSchema = true,
|
||||
autoMigrations = [
|
||||
AutoMigration(
|
||||
@@ -54,6 +54,10 @@ class ThumbKeyMigration : AutoMigrationSpec {
|
||||
from = 7,
|
||||
to = 8,
|
||||
),
|
||||
AutoMigration(
|
||||
from = 8,
|
||||
to = 9,
|
||||
),
|
||||
],
|
||||
)
|
||||
@TypeConverters(FilterModeConverter::class)
|
||||
|
||||
@@ -6,13 +6,13 @@ import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "DOWNLOAD_LABELS")
|
||||
data class DownloadLabel(
|
||||
@ColumnInfo(name = "LABEL")
|
||||
var label: String,
|
||||
|
||||
@ColumnInfo(name = "TIME")
|
||||
var time: Long,
|
||||
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "_id")
|
||||
var id: Long? = null,
|
||||
|
||||
@ColumnInfo(name = "LABEL")
|
||||
var label: String? = null,
|
||||
|
||||
@ColumnInfo(name = "TIME")
|
||||
var time: Long = 0,
|
||||
)
|
||||
@@ -78,7 +78,7 @@ object DownloadManager : OnSpiderListener {
|
||||
it.key to LinkedList(it.value)
|
||||
} as MutableMap<String?, LinkedList<DownloadInfo>>
|
||||
defaultInfoList = map.remove(null) ?: LinkedList()
|
||||
labelList.forEach { (_, label) ->
|
||||
labelList.forEach { (label) ->
|
||||
map[label] ?: LinkedList<DownloadInfo>().also { map[label] = it }
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ object DownloadManager : OnSpiderListener {
|
||||
if (label == null) {
|
||||
return false
|
||||
}
|
||||
for ((_, label1) in labelList) {
|
||||
for ((label1) in labelList) {
|
||||
if (label == label1) {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user