From a74ffca03daf1ae3e0507eaa1db4ed5493e8933b Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Tue, 24 Sep 2024 00:30:34 +0800 Subject: [PATCH] Fix galleries with both artist and cosplayer tags Legacy issue of E-Hentai's tag namespacing changes. --- app/src/main/kotlin/com/hippo/ehviewer/EhDB.kt | 2 +- .../main/kotlin/com/hippo/ehviewer/dao/DownloadArtistDao.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/EhDB.kt b/app/src/main/kotlin/com/hippo/ehviewer/EhDB.kt index 264c67663..782d6eea4 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/EhDB.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/EhDB.kt @@ -150,7 +150,7 @@ object EhDB { if (artists.isNotEmpty()) { val dao = db.downloadArtistDao() dao.deleteByGid(gid) - dao.insert(artists) + dao.insertOrIgnore(artists) } } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/dao/DownloadArtistDao.kt b/app/src/main/kotlin/com/hippo/ehviewer/dao/DownloadArtistDao.kt index d4db68150..3995d9527 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/dao/DownloadArtistDao.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/dao/DownloadArtistDao.kt @@ -2,12 +2,13 @@ package com.hippo.ehviewer.dao import androidx.room.Dao import androidx.room.Insert +import androidx.room.OnConflictStrategy import androidx.room.Query @Dao interface DownloadArtistDao { - @Insert - suspend fun insert(downloadArtists: List) + @Insert(onConflict = OnConflictStrategy.IGNORE) + suspend fun insertOrIgnore(downloadArtists: List) @Query("DELETE FROM DOWNLOAD_ARTISTS WHERE GID = :gid") suspend fun deleteByGid(gid: Long)