Ensure folder exists in library

This commit is contained in:
Nicholas Wallace 2024-08-31 21:45:14 -07:00
parent da82e2117b
commit 184858efae
2 changed files with 4 additions and 2 deletions

View file

@ -49,7 +49,8 @@ class MiscController {
return res.status(404).send(`Library not found with id ${libraryId}`)
}
const folder = await Database.libraryFolderModel.findByPk(folderId)
if (!folder) {
// Verify the folder matches the library ID so we don't accidentally add a podcast to the wrong path
if (!folder || folder.libraryId !== library.id) {
return res.status(404).send(`Folder not found with id ${folderId} in library ${library.name}`)
}

View file

@ -45,7 +45,8 @@ class PodcastController {
}
const folder = await Database.libraryFolderModel.findByPk(payload.folderId)
if (!folder) {
// Verify the folder matches the library ID so we don't accidentally add a podcast to the wrong path
if (!folder || folder.libraryId !== library.id) {
Logger.error(`[PodcastController] Create: Folder not found "${payload.folderId}"`)
return res.status(404).send('Folder not found')
}