mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 21:00:16 +02:00
refactor: rename TaskReceiver to TaskEmitter
This commit is contained in:
parent
b436e90a8c
commit
5787bbdaa2
16 changed files with 88 additions and 88 deletions
|
|
@ -24,7 +24,7 @@ import javax.jms.ConnectionFactory
|
|||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
@Service
|
||||
class TaskReceiver(
|
||||
class TaskEmitter(
|
||||
connectionFactory: ConnectionFactory,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val bookRepository: BookRepository,
|
||||
|
|
@ -30,7 +30,7 @@ private val logger = KotlinLogging.logger {}
|
|||
|
||||
@Service
|
||||
class TaskHandler(
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val bookRepository: BookRepository,
|
||||
private val seriesRepository: SeriesRepository,
|
||||
|
|
@ -58,32 +58,32 @@ class TaskHandler(
|
|||
is Task.ScanLibrary ->
|
||||
libraryRepository.findByIdOrNull(task.libraryId)?.let { library ->
|
||||
libraryContentLifecycle.scanRootFolder(library)
|
||||
taskReceiver.analyzeUnknownAndOutdatedBooks(library)
|
||||
taskReceiver.repairExtensions(library, LOW_PRIORITY)
|
||||
taskReceiver.findBooksToConvert(library, LOWEST_PRIORITY)
|
||||
taskReceiver.findBooksWithMissingPageHash(library, LOWEST_PRIORITY)
|
||||
taskReceiver.findDuplicatePagesToDelete(library, LOWEST_PRIORITY)
|
||||
taskReceiver.hashBooksWithoutHash(library)
|
||||
taskEmitter.analyzeUnknownAndOutdatedBooks(library)
|
||||
taskEmitter.repairExtensions(library, LOW_PRIORITY)
|
||||
taskEmitter.findBooksToConvert(library, LOWEST_PRIORITY)
|
||||
taskEmitter.findBooksWithMissingPageHash(library, LOWEST_PRIORITY)
|
||||
taskEmitter.findDuplicatePagesToDelete(library, LOWEST_PRIORITY)
|
||||
taskEmitter.hashBooksWithoutHash(library)
|
||||
} ?: logger.warn { "Cannot execute task $task: Library does not exist" }
|
||||
|
||||
is Task.FindBooksToConvert ->
|
||||
libraryRepository.findByIdOrNull(task.libraryId)?.let { library ->
|
||||
bookConverter.getConvertibleBooks(library).forEach {
|
||||
taskReceiver.convertBookToCbz(it, task.priority + 1)
|
||||
taskEmitter.convertBookToCbz(it, task.priority + 1)
|
||||
}
|
||||
} ?: logger.warn { "Cannot execute task $task: Library does not exist" }
|
||||
|
||||
is Task.FindBooksWithMissingPageHash ->
|
||||
libraryRepository.findByIdOrNull(task.libraryId)?.let { library ->
|
||||
pageHashLifecycle.getBookAndSeriesIdsWithMissingPageHash(library).forEach {
|
||||
taskReceiver.hashBookPages(it.first, it.second, task.priority + 1)
|
||||
taskEmitter.hashBookPages(it.first, it.second, task.priority + 1)
|
||||
}
|
||||
} ?: logger.warn { "Cannot execute task $task: Library does not exist" }
|
||||
|
||||
is Task.FindDuplicatePagesToDelete ->
|
||||
libraryRepository.findByIdOrNull(task.libraryId)?.let { library ->
|
||||
pageHashLifecycle.getBookPagesToDeleteAutomatically(library).forEach { (bookId, pages) ->
|
||||
taskReceiver.removeDuplicatePages(bookId, pages, task.priority + 1)
|
||||
taskEmitter.removeDuplicatePages(bookId, pages, task.priority + 1)
|
||||
}
|
||||
} ?: logger.warn { "Cannot execute task $task: Library does not exist" }
|
||||
|
||||
|
|
@ -95,8 +95,8 @@ class TaskHandler(
|
|||
is Task.AnalyzeBook ->
|
||||
bookRepository.findByIdOrNull(task.bookId)?.let { book ->
|
||||
if (bookLifecycle.analyzeAndPersist(book)) {
|
||||
taskReceiver.generateBookThumbnail(book, priority = task.priority + 1)
|
||||
taskReceiver.refreshBookMetadata(book, priority = task.priority + 1)
|
||||
taskEmitter.generateBookThumbnail(book, priority = task.priority + 1)
|
||||
taskEmitter.refreshBookMetadata(book, priority = task.priority + 1)
|
||||
}
|
||||
} ?: logger.warn { "Cannot execute task $task: Book does not exist" }
|
||||
|
||||
|
|
@ -108,13 +108,13 @@ class TaskHandler(
|
|||
is Task.RefreshBookMetadata ->
|
||||
bookRepository.findByIdOrNull(task.bookId)?.let { book ->
|
||||
bookMetadataLifecycle.refreshMetadata(book, task.capabilities)
|
||||
taskReceiver.refreshSeriesMetadata(book.seriesId, priority = task.priority - 1)
|
||||
taskEmitter.refreshSeriesMetadata(book.seriesId, priority = task.priority - 1)
|
||||
} ?: logger.warn { "Cannot execute task $task: Book does not exist" }
|
||||
|
||||
is Task.RefreshSeriesMetadata ->
|
||||
seriesRepository.findByIdOrNull(task.seriesId)?.let { series ->
|
||||
seriesMetadataLifecycle.refreshMetadata(series)
|
||||
taskReceiver.aggregateSeriesMetadata(series.id, priority = task.priority)
|
||||
taskEmitter.aggregateSeriesMetadata(series.id, priority = task.priority)
|
||||
} ?: logger.warn { "Cannot execute task $task: Series does not exist" }
|
||||
|
||||
is Task.AggregateSeriesMetadata ->
|
||||
|
|
@ -135,7 +135,7 @@ class TaskHandler(
|
|||
is Task.ImportBook ->
|
||||
seriesRepository.findByIdOrNull(task.seriesId)?.let { series ->
|
||||
val importedBook = bookImporter.importBook(Paths.get(task.sourceFile), series, task.copyMode, task.destinationName, task.upgradeBookId)
|
||||
taskReceiver.analyzeBook(importedBook, priority = task.priority + 1)
|
||||
taskEmitter.analyzeBook(importedBook, priority = task.priority + 1)
|
||||
} ?: logger.warn { "Cannot execute task $task: Series does not exist" }
|
||||
|
||||
is Task.ConvertBook ->
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.domain.service
|
|||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.CodedException
|
||||
import org.gotson.komga.domain.model.CopyMode
|
||||
|
|
@ -55,7 +55,7 @@ class BookImporter(
|
|||
private val libraryRepository: LibraryRepository,
|
||||
private val sidecarRepository: SidecarRepository,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
) {
|
||||
|
||||
fun importBook(sourceFile: Path, series: Series, copyMode: CopyMode, destinationName: String? = null, upgradeBookId: String? = null): Book {
|
||||
|
|
@ -195,8 +195,8 @@ class BookImporter(
|
|||
|
||||
sidecars.forEach { (sourceSidecar, destPath) ->
|
||||
when (sourceSidecar.type) {
|
||||
Sidecar.Type.ARTWORK -> taskReceiver.refreshBookLocalArtwork(importedBook)
|
||||
Sidecar.Type.METADATA -> taskReceiver.refreshBookMetadata(importedBook)
|
||||
Sidecar.Type.ARTWORK -> taskEmitter.refreshBookLocalArtwork(importedBook)
|
||||
Sidecar.Type.METADATA -> taskEmitter.refreshBookMetadata(importedBook)
|
||||
}
|
||||
val destSidecar = sourceSidecar.copy(
|
||||
url = destPath.toUri().toURL(),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.domain.service
|
|||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadataPatchCapability
|
||||
import org.gotson.komga.domain.model.BookSearch
|
||||
|
|
@ -50,7 +50,7 @@ class LibraryContentLifecycle(
|
|||
private val readListLifecycle: ReadListLifecycle,
|
||||
private val sidecarRepository: SidecarRepository,
|
||||
private val komgaProperties: KomgaProperties,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val hasher: Hasher,
|
||||
private val bookMetadataRepository: BookMetadataRepository,
|
||||
|
|
@ -190,7 +190,7 @@ class LibraryContentLifecycle(
|
|||
// for all series where books have been removed or added, trigger a sort and refresh metadata
|
||||
seriesToSortAndRefresh.distinctBy { it.id }.forEach {
|
||||
seriesLifecycle.sortBooks(it)
|
||||
taskReceiver.refreshSeriesMetadata(it.id)
|
||||
taskEmitter.refreshSeriesMetadata(it.id)
|
||||
}
|
||||
|
||||
val existingSidecars = sidecarRepository.findAll()
|
||||
|
|
@ -202,16 +202,16 @@ class LibraryContentLifecycle(
|
|||
seriesRepository.findNotDeletedByLibraryIdAndUrlOrNull(library.id, newSidecar.parentUrl)?.let { series ->
|
||||
logger.info { "Sidecar changed on disk (${newSidecar.url}, refresh Series for ${newSidecar.type}: $series" }
|
||||
when (newSidecar.type) {
|
||||
Sidecar.Type.ARTWORK -> taskReceiver.refreshSeriesLocalArtwork(series.id)
|
||||
Sidecar.Type.METADATA -> taskReceiver.refreshSeriesMetadata(series.id)
|
||||
Sidecar.Type.ARTWORK -> taskEmitter.refreshSeriesLocalArtwork(series.id)
|
||||
Sidecar.Type.METADATA -> taskEmitter.refreshSeriesMetadata(series.id)
|
||||
}
|
||||
}
|
||||
Sidecar.Source.BOOK ->
|
||||
bookRepository.findNotDeletedByLibraryIdAndUrlOrNull(library.id, newSidecar.parentUrl)?.let { book ->
|
||||
logger.info { "Sidecar changed on disk (${newSidecar.url}, refresh Book for ${newSidecar.type}: $book" }
|
||||
when (newSidecar.type) {
|
||||
Sidecar.Type.ARTWORK -> taskReceiver.refreshBookLocalArtwork(book)
|
||||
Sidecar.Type.METADATA -> taskReceiver.refreshBookMetadata(book)
|
||||
Sidecar.Type.ARTWORK -> taskEmitter.refreshBookLocalArtwork(book)
|
||||
Sidecar.Type.METADATA -> taskEmitter.refreshBookMetadata(book)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -351,7 +351,7 @@ class LibraryContentLifecycle(
|
|||
title = if (deleted.titleLock) deleted.title else newlyAdded.title,
|
||||
),
|
||||
)
|
||||
if (!deleted.titleLock) taskReceiver.refreshBookMetadata(bookToAdd, setOf(BookMetadataPatchCapability.TITLE))
|
||||
if (!deleted.titleLock) taskEmitter.refreshBookMetadata(bookToAdd, setOf(BookMetadataPatchCapability.TITLE))
|
||||
}
|
||||
|
||||
// copy read progress
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.domain.service
|
|||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.DirectoryNotFoundException
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.DuplicateNameException
|
||||
|
|
@ -24,7 +24,7 @@ class LibraryLifecycle(
|
|||
private val seriesLifecycle: SeriesLifecycle,
|
||||
private val seriesRepository: SeriesRepository,
|
||||
private val sidecarRepository: SidecarRepository,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
) {
|
||||
|
|
@ -42,7 +42,7 @@ class LibraryLifecycle(
|
|||
checkLibraryValidity(library, existing)
|
||||
|
||||
libraryRepository.insert(library)
|
||||
taskReceiver.scanLibrary(library.id)
|
||||
taskEmitter.scanLibrary(library.id)
|
||||
|
||||
eventPublisher.publishEvent(DomainEvent.LibraryAdded(library))
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ class LibraryLifecycle(
|
|||
checkLibraryValidity(toUpdate, existing)
|
||||
|
||||
libraryRepository.update(toUpdate)
|
||||
taskReceiver.scanLibrary(toUpdate.id)
|
||||
taskEmitter.scanLibrary(toUpdate.id)
|
||||
|
||||
eventPublisher.publishEvent(DomainEvent.LibraryUpdated(toUpdate))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import mu.KotlinLogging
|
|||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadata
|
||||
import org.gotson.komga.domain.model.BookMetadataAggregation
|
||||
|
|
@ -56,7 +56,7 @@ class SeriesLifecycle(
|
|||
private val bookMetadataAggregationRepository: BookMetadataAggregationRepository,
|
||||
private val collectionRepository: SeriesCollectionRepository,
|
||||
private val readProgressRepository: ReadProgressRepository,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
) {
|
||||
|
|
@ -103,7 +103,7 @@ class SeriesLifecycle(
|
|||
oldToNew.forEach { (book, old, new) ->
|
||||
if (old.number != new.number || old.numberSort != new.numberSort) {
|
||||
logger.debug { "Metadata numbering has changed, refreshing metadata for book ${new.bookId} " }
|
||||
taskReceiver.refreshBookMetadata(book, setOf(BookMetadataPatchCapability.NUMBER, BookMetadataPatchCapability.NUMBER_SORT))
|
||||
taskEmitter.refreshBookMetadata(book, setOf(BookMetadataPatchCapability.NUMBER, BookMetadataPatchCapability.NUMBER_SORT))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.apache.commons.io.IOUtils
|
|||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.HIGH_PRIORITY
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.BookSearchWithReadProgress
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.ImageConversionException
|
||||
|
|
@ -89,7 +89,7 @@ private val logger = KotlinLogging.logger {}
|
|||
@RestController
|
||||
@RequestMapping(produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||
class BookController(
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val bookLifecycle: BookLifecycle,
|
||||
private val bookRepository: BookRepository,
|
||||
private val bookMetadataRepository: BookMetadataRepository,
|
||||
|
|
@ -564,7 +564,7 @@ class BookController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun analyze(@PathVariable bookId: String) {
|
||||
bookRepository.findByIdOrNull(bookId)?.let { book ->
|
||||
taskReceiver.analyzeBook(book, HIGH_PRIORITY)
|
||||
taskEmitter.analyzeBook(book, HIGH_PRIORITY)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
|
|
@ -573,8 +573,8 @@ class BookController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun refreshMetadata(@PathVariable bookId: String) {
|
||||
bookRepository.findByIdOrNull(bookId)?.let { book ->
|
||||
taskReceiver.refreshBookMetadata(book, priority = HIGH_PRIORITY)
|
||||
taskReceiver.refreshBookLocalArtwork(book, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookMetadata(book, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookLocalArtwork(book, priority = HIGH_PRIORITY)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
|
|
@ -591,7 +591,7 @@ class BookController(
|
|||
bookMetadataRepository.update(updated)
|
||||
|
||||
bookRepository.findByIdOrNull(bookId)?.let { updatedBook ->
|
||||
taskReceiver.aggregateSeriesMetadata(updatedBook.seriesId)
|
||||
taskEmitter.aggregateSeriesMetadata(updatedBook.seriesId)
|
||||
updatedBook.let { eventPublisher.publishEvent(DomainEvent.BookUpdated(it)) }
|
||||
}
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
|
|
@ -613,7 +613,7 @@ class BookController(
|
|||
}
|
||||
|
||||
updatedBooks.forEach { eventPublisher.publishEvent(DomainEvent.BookUpdated(it)) }
|
||||
updatedBooks.map { it.seriesId }.distinct().forEach { taskReceiver.aggregateSeriesMetadata(it) }
|
||||
updatedBooks.map { it.seriesId }.distinct().forEach { taskEmitter.aggregateSeriesMetadata(it) }
|
||||
}
|
||||
|
||||
@Operation(description = "Mark book as read and/or change page progress")
|
||||
|
|
@ -661,7 +661,7 @@ class BookController(
|
|||
) {
|
||||
bookImportBatch.books.forEach {
|
||||
try {
|
||||
taskReceiver.importBook(
|
||||
taskEmitter.importBook(
|
||||
sourceFile = it.sourceFile,
|
||||
seriesId = it.seriesId,
|
||||
copyMode = bookImportBatch.copyMode,
|
||||
|
|
@ -681,7 +681,7 @@ class BookController(
|
|||
fun deleteBook(
|
||||
@PathVariable bookId: String,
|
||||
) {
|
||||
taskReceiver.deleteBook(
|
||||
taskEmitter.deleteBook(
|
||||
bookId = bookId,
|
||||
priority = HIGHEST_PRIORITY,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.interfaces.api.rest
|
|||
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.HIGH_PRIORITY
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.BookSearch
|
||||
import org.gotson.komga.domain.model.DirectoryNotFoundException
|
||||
import org.gotson.komga.domain.model.DuplicateNameException
|
||||
|
|
@ -40,7 +40,7 @@ import javax.validation.Valid
|
|||
@RestController
|
||||
@RequestMapping("api/v1/libraries", produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||
class LibraryController(
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val libraryLifecycle: LibraryLifecycle,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val bookRepository: BookRepository,
|
||||
|
|
@ -171,7 +171,7 @@ class LibraryController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun scan(@PathVariable libraryId: String) {
|
||||
libraryRepository.findByIdOrNull(libraryId)?.let { library ->
|
||||
taskReceiver.scanLibrary(library.id, HIGHEST_PRIORITY)
|
||||
taskEmitter.scanLibrary(library.id, HIGHEST_PRIORITY)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ class LibraryController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun analyze(@PathVariable libraryId: String) {
|
||||
bookRepository.findAll(BookSearch(libraryIds = listOf(libraryId))).forEach {
|
||||
taskReceiver.analyzeBook(it, HIGH_PRIORITY)
|
||||
taskEmitter.analyzeBook(it, HIGH_PRIORITY)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -189,11 +189,11 @@ class LibraryController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun refreshMetadata(@PathVariable libraryId: String) {
|
||||
bookRepository.findAll(BookSearch(libraryIds = listOf(libraryId))).forEach {
|
||||
taskReceiver.refreshBookMetadata(it, priority = HIGH_PRIORITY)
|
||||
taskReceiver.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookMetadata(it, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
}
|
||||
seriesRepository.findAllIdsByLibraryId(libraryId).forEach {
|
||||
taskReceiver.refreshSeriesLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshSeriesLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ class LibraryController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun emptyTrash(@PathVariable libraryId: String) {
|
||||
libraryRepository.findByIdOrNull(libraryId)?.let { library ->
|
||||
taskReceiver.emptyTrash(library.id, HIGH_PRIORITY)
|
||||
taskEmitter.emptyTrash(library.id, HIGH_PRIORITY)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.Parameter
|
|||
import io.swagger.v3.oas.annotations.media.Content
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.BookPageNumbered
|
||||
import org.gotson.komga.domain.model.PageHash
|
||||
import org.gotson.komga.domain.model.PageHashKnown
|
||||
|
|
@ -42,7 +42,7 @@ import javax.validation.Valid
|
|||
class PageHashController(
|
||||
private val pageHashRepository: PageHashRepository,
|
||||
private val pageHashLifecycle: PageHashLifecycle,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
) {
|
||||
|
||||
@GetMapping
|
||||
|
|
@ -143,7 +143,7 @@ class PageHashController(
|
|||
},
|
||||
)
|
||||
|
||||
toRemove.forEach { taskReceiver.removeDuplicatePages(it.key, it.value) }
|
||||
toRemove.forEach { taskEmitter.removeDuplicatePages(it.key, it.value) }
|
||||
}
|
||||
|
||||
@PostMapping("{pageHash}/delete-match")
|
||||
|
|
@ -167,6 +167,6 @@ class PageHashController(
|
|||
),
|
||||
)
|
||||
|
||||
taskReceiver.removeDuplicatePages(toRemove.first, toRemove.second)
|
||||
taskEmitter.removeDuplicatePages(toRemove.first, toRemove.second)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import org.apache.commons.io.IOUtils
|
|||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.HIGH_PRIORITY
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Author
|
||||
import org.gotson.komga.domain.model.BookSearchWithReadProgress
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
|
|
@ -93,7 +93,7 @@ private val logger = KotlinLogging.logger {}
|
|||
@RestController
|
||||
@RequestMapping("api", produces = [MediaType.APPLICATION_JSON_VALUE])
|
||||
class SeriesController(
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val seriesRepository: SeriesRepository,
|
||||
private val seriesLifecycle: SeriesLifecycle,
|
||||
private val seriesMetadataRepository: SeriesMetadataRepository,
|
||||
|
|
@ -490,7 +490,7 @@ class SeriesController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun analyze(@PathVariable seriesId: String) {
|
||||
bookRepository.findAllBySeriesId(seriesId).forEach {
|
||||
taskReceiver.analyzeBook(it, HIGH_PRIORITY)
|
||||
taskEmitter.analyzeBook(it, HIGH_PRIORITY)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -499,10 +499,10 @@ class SeriesController(
|
|||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
fun refreshMetadata(@PathVariable seriesId: String) {
|
||||
bookRepository.findAllBySeriesId(seriesId).forEach {
|
||||
taskReceiver.refreshBookMetadata(it, priority = HIGH_PRIORITY)
|
||||
taskReceiver.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookMetadata(it, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY)
|
||||
}
|
||||
taskReceiver.refreshSeriesLocalArtwork(seriesId, priority = HIGH_PRIORITY)
|
||||
taskEmitter.refreshSeriesLocalArtwork(seriesId, priority = HIGH_PRIORITY)
|
||||
}
|
||||
|
||||
@PatchMapping("v1/series/{seriesId}/metadata")
|
||||
|
|
@ -695,7 +695,7 @@ class SeriesController(
|
|||
fun deleteSeries(
|
||||
@PathVariable seriesId: String,
|
||||
) {
|
||||
taskReceiver.deleteSeries(
|
||||
taskEmitter.deleteSeries(
|
||||
seriesId = seriesId,
|
||||
priority = HIGHEST_PRIORITY,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.gotson.komga.interfaces.scheduler
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||
import org.springframework.context.annotation.Profile
|
||||
import org.springframework.context.event.EventListener
|
||||
|
|
@ -13,13 +13,13 @@ private val logger = KotlinLogging.logger {}
|
|||
@Profile("!test")
|
||||
@Component
|
||||
class PeriodicScannerController(
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
) {
|
||||
|
||||
@EventListener(classes = [ApplicationReadyEvent::class], condition = "@komgaProperties.librariesScanStartup")
|
||||
@Scheduled(cron = "#{@komgaProperties.librariesScanCron ?: '-'}")
|
||||
fun scanAllLibraries() {
|
||||
logger.info { "Periodic libraries scan starting" }
|
||||
taskReceiver.scanLibraries()
|
||||
taskEmitter.scanLibraries()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.gotson.komga.interfaces.scheduler
|
|||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.infrastructure.search.LuceneEntity
|
||||
import org.gotson.komga.infrastructure.search.LuceneHelper
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||
|
|
@ -16,19 +16,19 @@ private val logger = KotlinLogging.logger {}
|
|||
@Component
|
||||
class SearchIndexController(
|
||||
private val luceneHelper: LuceneHelper,
|
||||
private val taskReceiver: TaskReceiver,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
) {
|
||||
|
||||
@EventListener(ApplicationReadyEvent::class)
|
||||
fun createIndexIfNoneExist() {
|
||||
if (!luceneHelper.indexExists()) {
|
||||
logger.info { "Lucene index not found, trigger rebuild" }
|
||||
taskReceiver.rebuildIndex(HIGHEST_PRIORITY)
|
||||
taskEmitter.rebuildIndex(HIGHEST_PRIORITY)
|
||||
} else {
|
||||
logger.info { "Lucene index version: ${luceneHelper.getIndexVersion()}" }
|
||||
when (luceneHelper.getIndexVersion()) {
|
||||
1, 2 -> taskReceiver.rebuildIndex(HIGHEST_PRIORITY)
|
||||
3 -> taskReceiver.rebuildIndex(HIGHEST_PRIORITY, setOf(LuceneEntity.Series))
|
||||
1, 2 -> taskEmitter.rebuildIndex(HIGHEST_PRIORITY)
|
||||
3 -> taskEmitter.rebuildIndex(HIGHEST_PRIORITY, setOf(LuceneEntity.Series))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ private val logger = KotlinLogging.logger {}
|
|||
@ExtendWith(SpringExtension::class)
|
||||
@SpringBootTest
|
||||
class TaskHandlerTest(
|
||||
@Autowired private val taskReceiver: TaskReceiver,
|
||||
@Autowired private val taskEmitter: TaskEmitter,
|
||||
@Autowired private val jmsTemplate: JmsTemplate,
|
||||
@Autowired private val jmsListenerEndpointRegistry: JmsListenerEndpointRegistry,
|
||||
) {
|
||||
|
|
@ -68,7 +68,7 @@ class TaskHandlerTest(
|
|||
jmsListenerEndpointRegistry.stop()
|
||||
val book = makeBook("book")
|
||||
repeat(100) {
|
||||
taskReceiver.analyzeBook(book)
|
||||
taskEmitter.analyzeBook(book)
|
||||
}
|
||||
jmsListenerEndpointRegistry.start()
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class TaskHandlerTest(
|
|||
|
||||
jmsListenerEndpointRegistry.stop()
|
||||
(0..9).forEach {
|
||||
taskReceiver.analyzeBook(makeBook("$it", id = "$it"), it)
|
||||
taskEmitter.analyzeBook(makeBook("$it", id = "$it"), it)
|
||||
}
|
||||
jmsListenerEndpointRegistry.start()
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ class TaskHandlerTest(
|
|||
|
||||
jmsListenerEndpointRegistry.stop()
|
||||
(0..9).forEach {
|
||||
taskReceiver.refreshSeriesMetadata("$it", it)
|
||||
taskEmitter.refreshSeriesMetadata("$it", it)
|
||||
}
|
||||
jmsListenerEndpointRegistry.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import io.mockk.just
|
|||
import io.mockk.verify
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.BookPage
|
||||
import org.gotson.komga.domain.model.CopyMode
|
||||
import org.gotson.komga.domain.model.KomgaUser
|
||||
|
|
@ -66,7 +66,7 @@ class BookImporterTest(
|
|||
private val user2 = KomgaUser("user2@example.org", "", false)
|
||||
|
||||
@MockkBean
|
||||
private lateinit var mockTackReceiver: TaskReceiver
|
||||
private lateinit var mockTackReceiver: TaskEmitter
|
||||
|
||||
@BeforeAll
|
||||
fun init() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import io.mockk.slot
|
|||
import io.mockk.verify
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.catchThrowable
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadataPatchCapability
|
||||
import org.gotson.komga.domain.model.DirectoryNotFoundException
|
||||
|
|
@ -88,7 +88,7 @@ class LibraryContentLifecycleTest(
|
|||
private lateinit var mockHasher: Hasher
|
||||
|
||||
@MockkBean
|
||||
private lateinit var mockTaskReceiver: TaskReceiver
|
||||
private lateinit var mockTaskEmitter: TaskEmitter
|
||||
|
||||
private val user = KomgaUser("user@example.org", "", false, id = "1")
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ class LibraryContentLifecycleTest(
|
|||
|
||||
@BeforeEach
|
||||
fun beforeEach() {
|
||||
every { mockTaskReceiver.refreshBookMetadata(any(), any()) } just Runs
|
||||
every { mockTaskReceiver.refreshSeriesMetadata(any(), any()) } just Runs
|
||||
every { mockTaskEmitter.refreshBookMetadata(any(), any()) } just Runs
|
||||
every { mockTaskEmitter.refreshSeriesMetadata(any(), any()) } just Runs
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
@ -855,7 +855,7 @@ class LibraryContentLifecycleTest(
|
|||
|
||||
// then
|
||||
verify(exactly = 1) { mockHasher.computeHash(any<Path>()) }
|
||||
verify(exactly = 0) { mockTaskReceiver.refreshBookMetadata(bookRenamed, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
verify(exactly = 0) { mockTaskEmitter.refreshBookMetadata(bookRenamed, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
|
||||
val allSeries = seriesRepository.findAll()
|
||||
val allBooks = bookRepository.findAll().sortedBy { it.number }
|
||||
|
|
@ -899,7 +899,7 @@ class LibraryContentLifecycleTest(
|
|||
|
||||
// then
|
||||
verify(exactly = 1) { mockHasher.computeHash(any<Path>()) }
|
||||
verify(exactly = 1) { mockTaskReceiver.refreshBookMetadata(withArg { assertThat(it.id).isEqualTo(bookRenamed.id) }, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
verify(exactly = 1) { mockTaskEmitter.refreshBookMetadata(withArg { assertThat(it.id).isEqualTo(bookRenamed.id) }, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
|
||||
val allSeries = seriesRepository.findAll()
|
||||
val allBooks = bookRepository.findAll().sortedBy { it.number }
|
||||
|
|
@ -1224,7 +1224,7 @@ class LibraryContentLifecycleTest(
|
|||
libraryContentLifecycle.scanRootFolder(library) // rename
|
||||
|
||||
// then
|
||||
verify(exactly = 0) { mockTaskReceiver.refreshBookMetadata(book2Moved, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
verify(exactly = 0) { mockTaskEmitter.refreshBookMetadata(book2Moved, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
|
||||
val allSeries = seriesRepository.findAll()
|
||||
val allBooks = bookRepository.findAll().sortedBy { it.number }
|
||||
|
|
@ -1282,7 +1282,7 @@ class LibraryContentLifecycleTest(
|
|||
libraryContentLifecycle.scanRootFolder(library) // rename
|
||||
|
||||
// then
|
||||
verify(exactly = 1) { mockTaskReceiver.refreshBookMetadata(withArg { assertThat(it.id).isEqualTo(book2Moved.id) }, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
verify(exactly = 1) { mockTaskEmitter.refreshBookMetadata(withArg { assertThat(it.id).isEqualTo(book2Moved.id) }, setOf(BookMetadataPatchCapability.TITLE)) }
|
||||
|
||||
val allSeries = seriesRepository.findAll()
|
||||
val allBooks = bookRepository.findAll().sortedBy { it.number }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import io.mockk.Runs
|
|||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.gotson.komga.application.tasks.TaskReceiver
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.ReadList
|
||||
import org.gotson.komga.domain.model.ReadListRequest
|
||||
import org.gotson.komga.domain.model.ReadListRequestBook
|
||||
|
|
@ -43,7 +43,7 @@ class ReadListMatcherTest(
|
|||
private val library = makeLibrary()
|
||||
|
||||
@MockkBean
|
||||
private lateinit var mockTaskReceiver: TaskReceiver
|
||||
private lateinit var mockTaskEmitter: TaskEmitter
|
||||
|
||||
@BeforeAll
|
||||
fun `setup library`() {
|
||||
|
|
@ -52,7 +52,7 @@ class ReadListMatcherTest(
|
|||
|
||||
@BeforeEach
|
||||
fun beforeEach() {
|
||||
every { mockTaskReceiver.refreshBookMetadata(any(), any()) } just Runs
|
||||
every { mockTaskEmitter.refreshBookMetadata(any(), any()) } just Runs
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
|
|||
Loading…
Reference in a new issue