From 4b91a7e3f9112796b1a93a5e40ede2f8a2ef3ce4 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:15:26 +0200 Subject: [PATCH] added podcast support --- client/pages/upload/index.vue | 6 +++++- server/controllers/MiscController.js | 9 ++++----- server/utils/fileUtils.js | 4 ---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/pages/upload/index.vue b/client/pages/upload/index.vue index 3043382c..3216838f 100644 --- a/client/pages/upload/index.vue +++ b/client/pages/upload/index.vue @@ -364,7 +364,11 @@ export default { const containsAudio = item.files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1))) const exists = await this.$axios - .$post(`/api/filesystem/pathexists`, { directory: item.directory, folderPath: this.selectedFolder.fullPath, filenames: item.files.map((f) => f.name), allowBookFiles: !containsBook, allowAudioFiles: !containsAudio }) + .$post(`/api/filesystem/pathexists`, { directory: item.directory, folderPath: this.selectedFolder.fullPath, filenames: item.files.map((f) => f.name), + ...(this.selectedLibrary.mediaType === 'podcast' + ? { allowBookFiles: !containsBook, allowAudioFiles: true } + : { allowBookFiles: !containsBook, allowAudioFiles: !containsAudio }) + }) .then((data) => { if (data.exists) { if (data.libraryItemTitle) { diff --git a/server/controllers/MiscController.js b/server/controllers/MiscController.js index 494f854f..5d5c718a 100644 --- a/server/controllers/MiscController.js +++ b/server/controllers/MiscController.js @@ -44,9 +44,8 @@ class MiscController { } const files = Object.values(req.files) - // If allowAdditionalFiles is true, the upload endpoint allows adding items even if the type of file already exists in the library. // If allowOverwrite is true, it will allow overwriting existing files. - let { title, author, series, folder: folderId, library: libraryId, allowAdditionalFiles, allowOverwrite } = req.body + let { title, author, series, folder: folderId, library: libraryId, allowOverwrite } = req.body // Validate request body if (!libraryId || !folderId || typeof libraryId !== 'string' || typeof folderId !== 'string' || !title || typeof title !== 'string') { return res.status(400).send('Invalid request body') @@ -82,10 +81,10 @@ class MiscController { const outputDirectory = Path.join(...[folder.path, ...cleanedOutputDirectoryParts]) if (allowOverwrite === undefined || allowOverwrite === null || !allowOverwrite) { - const containsBook = allowAdditionalFiles || files.some(file => globals.SupportedEbookTypes.includes(Path.extname(file.name).toLowerCase().slice(1))) - const containsAudio = allowAdditionalFiles || files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1))) + const containsBook = files.some(file => globals.SupportedEbookTypes.includes(Path.extname(file.name).toLowerCase().slice(1))) + const containsAudio = files.some(file => globals.SupportedAudioTypes.includes(Path.extname(file.name).toLowerCase().slice(1))) - if ((await validatePathExists(folder, outputDirectory, files.map((f) => f.name), !containsBook, !containsAudio, true)).exists) { + if ((await validatePathExists(folder, outputDirectory, files.map((f) => f.name), !containsBook, library.mediaType === 'podcast' || !containsAudio, true)).exists) { Logger.error(`Upload path already exists: ${outputDirectory}`) return res.status(400).send('Uploaded file already exists') } diff --git a/server/utils/fileUtils.js b/server/utils/fileUtils.js index c6287648..3d557708 100644 --- a/server/utils/fileUtils.js +++ b/server/utils/fileUtils.js @@ -630,10 +630,6 @@ module.exports.validatePathExists = async function validatePathExists( if (hasRestrictedFiles) { return { exists: true }; } - } else { - return { - exists: true, - }; } } }