mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-01 16:54:59 +02:00
Merge pull request #4223 from Vito0912/feat/fixCrashEmptyCollection
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Run Component Tests / Run Component Tests (push) Waiting to run
Build and Push Docker Image / build (push) Waiting to run
Verify all i18n files are alphabetized / update_translations (push) Waiting to run
Integration Test / build and test (push) Waiting to run
Run Unit Tests / Run Unit Tests (push) Waiting to run
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Run Component Tests / Run Component Tests (push) Waiting to run
Build and Push Docker Image / build (push) Waiting to run
Verify all i18n files are alphabetized / update_translations (push) Waiting to run
Integration Test / build and test (push) Waiting to run
Run Unit Tests / Run Unit Tests (push) Waiting to run
Fix server crash when a user requests the RSS feed of an empty collection
This commit is contained in:
commit
ec05bd36e4
1 changed files with 7 additions and 3 deletions
|
@ -215,9 +215,13 @@ class FeedEpisode extends Model {
|
|||
* @returns {Promise<FeedEpisode[]>}
|
||||
*/
|
||||
static async createFromBooks(books, feed, slug, transaction) {
|
||||
const earliestLibraryItemCreatedAt = books.reduce((earliest, book) => {
|
||||
return book.libraryItem.createdAt < earliest.libraryItem.createdAt ? book : earliest
|
||||
}).libraryItem.createdAt
|
||||
// This is never null unless the books array is empty, as this method is not invoked when no books. Reduce needs an initial item
|
||||
const earliestLibraryItemCreatedAt =
|
||||
books.length > 0
|
||||
? books.reduce((earliest, book) => {
|
||||
return book.libraryItem.createdAt < earliest.libraryItem.createdAt ? book : earliest
|
||||
}).libraryItem.createdAt
|
||||
: null
|
||||
|
||||
const feedEpisodeObjs = []
|
||||
let numExisting = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue