Skip to content

Commit

Permalink
fix: sidecars would not be deleted with library
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Jun 17, 2021
1 parent 1a1f1cd commit 49f83b7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DELETE
FROM SIDECAR
WHERE LIBRARY_ID NOT IN (
SELECT ID
FROM LIBRARY
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ interface SidecarRepository {
fun save(libraryId: String, sidecar: Sidecar)

fun deleteByLibraryIdAndUrls(libraryId: String, urls: Collection<URL>)
fun deleteByLibraryId(libraryId: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gotson.komga.domain.model.Library
import org.gotson.komga.domain.model.PathContainedInPath
import org.gotson.komga.domain.persistence.LibraryRepository
import org.gotson.komga.domain.persistence.SeriesRepository
import org.gotson.komga.domain.persistence.SidecarRepository
import org.springframework.stereotype.Service
import java.io.FileNotFoundException
import java.nio.file.Files
Expand All @@ -19,6 +20,7 @@ class LibraryLifecycle(
private val libraryRepository: LibraryRepository,
private val seriesLifecycle: SeriesLifecycle,
private val seriesRepository: SeriesRepository,
private val sidecarRepository: SidecarRepository,
private val taskReceiver: TaskReceiver
) {

Expand Down Expand Up @@ -73,6 +75,7 @@ class LibraryLifecycle(

val seriesIds = seriesRepository.findAllByLibraryId(library.id).map { it.id }
seriesLifecycle.deleteMany(seriesIds)
sidecarRepository.deleteByLibraryId(library.id)

libraryRepository.delete(library.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class SidecarDao(
.execute()
}

override fun deleteByLibraryId(libraryId: String) {
dsl.deleteFrom(sc)
.where(sc.LIBRARY_ID.eq(libraryId))
.execute()
}

private fun SidecarRecord.toDomain() =
SidecarStored(
url = URL(url),
Expand Down

0 comments on commit 49f83b7

Please sign in to comment.