From c72eac998703e2d3b5bcaf25a95bb7bdcb149855 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 25 Aug 2024 17:13:09 -0500 Subject: [PATCH] Fix:Check if book is already being merged before allowing to start #3331 --- server/controllers/ToolsController.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/controllers/ToolsController.js b/server/controllers/ToolsController.js index 32cd5a6c..adc91870 100644 --- a/server/controllers/ToolsController.js +++ b/server/controllers/ToolsController.js @@ -29,12 +29,17 @@ class ToolsController { if (req.libraryItem.mediaType !== 'book') { Logger.error(`[MiscController] encodeM4b: Invalid library item ${req.params.id}: not a book`) - return res.status(500).send('Invalid library item: not a book') + return res.status(400).send('Invalid library item: not a book') } if (req.libraryItem.media.tracks.length <= 0) { Logger.error(`[MiscController] encodeM4b: Invalid audiobook ${req.params.id}: no audio tracks`) - return res.status(500).send('Invalid audiobook: no audio tracks') + return res.status(400).send('Invalid audiobook: no audio tracks') + } + + if (this.abMergeManager.getPendingTaskByLibraryItemId(req.libraryItem.id)) { + Logger.error(`[MiscController] encodeM4b: Audiobook ${req.params.id} is already in queue or processing`) + return res.status(400).send('Audiobook is already in queue or processing') } const options = req.query || {}