diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration20To21.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration20To21.kt new file mode 100644 index 000000000..462b77261 --- /dev/null +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration20To21.kt @@ -0,0 +1,12 @@ +package org.koitharu.kotatsu.core.db.migrations + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +class Migration20To21 : Migration(20, 21) { + + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE tracks ADD COLUMN `last_error` TEXT DEFAULT NULL") + db.execSQL("ALTER TABLE sources ADD COLUMN `added_in` INTEGER NOT NULL DEFAULT 0") + } +} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/data/TrackEntity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/data/TrackEntity.kt index c152253ac..127a60b4c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/data/TrackEntity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/data/TrackEntity.kt @@ -25,6 +25,7 @@ class TrackEntity( @ColumnInfo(name = "last_check_time") val lastCheckTime: Long, @ColumnInfo(name = "last_chapter_date") val lastChapterDate: Long, @ColumnInfo(name = "last_result") val lastResult: Int, + @ColumnInfo(name = "last_error") val lastError: String?, ) { companion object { @@ -42,6 +43,7 @@ class TrackEntity( lastCheckTime = 0L, lastChapterDate = 0, lastResult = RESULT_NONE, + lastError = null, ) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt index e4f60dee0..58bd10e95 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt @@ -168,6 +168,7 @@ class TrackingRepository @Inject constructor( lastCheckTime = tracking.lastCheck?.toEpochMilli() ?: 0L, lastChapterDate = tracking.lastChapterDate?.toEpochMilli() ?: 0L, lastResult = TrackEntity.RESULT_EXTERNAL_MODIFICATION, + lastError = null, ) db.getTracksDao().upsert(entity) } @@ -224,6 +225,7 @@ class TrackingRepository @Inject constructor( lastCheckTime = System.currentTimeMillis(), lastChapterDate = lastChapterDate, lastResult = TrackEntity.RESULT_FAILED, + lastError = updates.error?.toString(), ) is MangaUpdates.Success -> TrackEntity( @@ -233,6 +235,7 @@ class TrackingRepository @Inject constructor( lastCheckTime = System.currentTimeMillis(), lastChapterDate = updates.lastChapterDate().ifZero { lastChapterDate }, lastResult = if (updates.isNotEmpty()) TrackEntity.RESULT_HAS_UPDATE else TrackEntity.RESULT_NO_UPDATE, + lastError = null, ) } }