diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index a91db75c4..ee30c1cc4 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -12,8 +12,8 @@ import io.legado.app.data.entities.* @Database( entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class, ReplaceRule::class, - SearchBook::class, SearchKeyword::class, SourceCookie::class, RssSource::class, Bookmark::class, - RssArticle::class, Cookie::class], + SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, + RssArticle::class], version = 1, exportSchema = true ) @@ -56,7 +56,6 @@ abstract class AppDatabase : RoomDatabase() { abstract fun replaceRuleDao(): ReplaceRuleDao abstract fun searchBookDao(): SearchBookDao abstract fun searchKeywordDao(): SearchKeywordDao - abstract fun sourceCookieDao(): SourceCookieDao abstract fun rssSourceDao(): RssSourceDao abstract fun bookmarkDao(): BookmarkDao abstract fun rssArticleDao(): RssArticleDao diff --git a/app/src/main/java/io/legado/app/data/dao/CookieDao.kt b/app/src/main/java/io/legado/app/data/dao/CookieDao.kt index f2adba4aa..1ec8c99e3 100644 --- a/app/src/main/java/io/legado/app/data/dao/CookieDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/CookieDao.kt @@ -6,10 +6,9 @@ import io.legado.app.data.entities.Cookie @Dao interface CookieDao { - @Query("select * from cookies where url = :url") + @Query("SELECT * FROM cookies Where url = :url") fun get(url: String): Cookie? - @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg cookie: Cookie) diff --git a/app/src/main/java/io/legado/app/data/dao/SourceCookieDao.kt b/app/src/main/java/io/legado/app/data/dao/SourceCookieDao.kt deleted file mode 100644 index fcf4abf70..000000000 --- a/app/src/main/java/io/legado/app/data/dao/SourceCookieDao.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.legado.app.data.dao - -import androidx.room.Dao -import androidx.room.Query - -@Dao -interface SourceCookieDao { - - @Query("SELECT cookie FROM cookies Where url = :url") - fun getCookieByUrl(url: String): String? - -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/Cookie.kt b/app/src/main/java/io/legado/app/data/entities/Cookie.kt index d5952e194..8e12febf4 100644 --- a/app/src/main/java/io/legado/app/data/entities/Cookie.kt +++ b/app/src/main/java/io/legado/app/data/entities/Cookie.kt @@ -1,11 +1,12 @@ package io.legado.app.data.entities import androidx.room.Entity +import androidx.room.Index import androidx.room.PrimaryKey -@Entity(tableName = "cookies") +@Entity(tableName = "cookies", indices = [(Index(value = ["url"], unique = true))]) data class Cookie( @PrimaryKey var url: String = "", - var cookie: String? = null + var cookie: String = "" ) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/SourceCookie.kt b/app/src/main/java/io/legado/app/data/entities/SourceCookie.kt deleted file mode 100644 index 62581a2f8..000000000 --- a/app/src/main/java/io/legado/app/data/entities/SourceCookie.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.legado.app.data.entities - -import androidx.room.Entity -import androidx.room.Index -import androidx.room.PrimaryKey - -@Entity(tableName = "cookies", indices = [(Index(value = ["url"], unique = true))]) -data class SourceCookie( - @PrimaryKey - var url: String = "", - var cookie: String = "" -) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/http/CookieStore.kt b/app/src/main/java/io/legado/app/help/http/CookieStore.kt index 56b7aff28..4d6ccb6d3 100644 --- a/app/src/main/java/io/legado/app/help/http/CookieStore.kt +++ b/app/src/main/java/io/legado/app/help/http/CookieStore.kt @@ -9,7 +9,7 @@ object CookieStore { fun setCookie(url: String, cookie: String?) { try { - val cookieBean = Cookie(url, cookie) + val cookieBean = Cookie(url, cookie ?: "") App.db.cookieDao().insert(cookieBean) } catch (ignore: Exception) { }