mirror of
https://github.com/gotson/komga.git
synced 2025-12-20 07:23:34 +01:00
parent
6e106f1da7
commit
19204df1c7
1 changed files with 17 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import org.gotson.komga.jooq.Tables
|
|||
import org.gotson.komga.jooq.tables.records.SidecarRecord
|
||||
import org.jooq.DSLContext
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.net.URL
|
||||
|
||||
@Component
|
||||
|
|
@ -15,6 +16,7 @@ class SidecarDao(
|
|||
) : SidecarRepository {
|
||||
|
||||
private val sc = Tables.SIDECAR
|
||||
private val u = Tables.TEMP_URL_LIST
|
||||
|
||||
override fun findAll(): Collection<SidecarStored> =
|
||||
dsl.selectFrom(sc).fetch().map { it.toDomain() }
|
||||
|
|
@ -34,10 +36,24 @@ class SidecarDao(
|
|||
.execute()
|
||||
}
|
||||
|
||||
@Transactional
|
||||
override fun deleteByLibraryIdAndUrls(libraryId: String, urls: Collection<URL>) {
|
||||
// insert urls in a temporary table, else the select size can exceed the statement limit
|
||||
dsl.deleteFrom(u).execute()
|
||||
|
||||
if (urls.isNotEmpty()) {
|
||||
dsl.batch(
|
||||
dsl.insertInto(u, u.URL).values(null as String?)
|
||||
).also { step ->
|
||||
urls.forEach {
|
||||
step.bind(it.toString())
|
||||
}
|
||||
}.execute()
|
||||
}
|
||||
|
||||
dsl.deleteFrom(sc)
|
||||
.where(sc.LIBRARY_ID.eq(libraryId))
|
||||
.and(sc.URL.`in`(urls.map { it.toString() }))
|
||||
.and(sc.URL.`in`(dsl.select(u.URL).from(u)))
|
||||
.execute()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue