From 778256ca165fb1248cdb5463146ac4e0561f2c82 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 18 Nov 2024 07:42:24 -0600 Subject: [PATCH] Fix:Server crash on new libraries when getting filter data #3623 --- server/utils/queries/libraryFilters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/utils/queries/libraryFilters.js b/server/utils/queries/libraryFilters.js index 64ad07ee..be164eb2 100644 --- a/server/utils/queries/libraryFilters.js +++ b/server/utils/queries/libraryFilters.js @@ -510,7 +510,7 @@ module.exports = { // If nothing has changed, check if the number of podcasts in // library is still the same as prior check before updating cache creation time - if (podcastCountFromDatabase === Database.libraryFilterData[libraryId].podcastCount) { + if (podcastCountFromDatabase === Database.libraryFilterData[libraryId]?.podcastCount) { Logger.debug(`Filter data for ${libraryId} has not changed, returning cached data and updating cache time after ${((Date.now() - start) / 1000).toFixed(2)}s`) Database.libraryFilterData[libraryId].loadedAt = Date.now() return cachedFilterData @@ -613,7 +613,7 @@ module.exports = { if (changedBooks + changedSeries + changedAuthors === 0) { // If nothing has changed, check if the number of authors, series, and books // matches the prior check before updating cache creation time - if (bookCountFromDatabase === Database.libraryFilterData[libraryId].bookCount && seriesCountFromDatabase === Database.libraryFilterData[libraryId].seriesCount && authorCountFromDatabase === Database.libraryFilterData[libraryId].authorCount) { + if (bookCountFromDatabase === Database.libraryFilterData[libraryId]?.bookCount && seriesCountFromDatabase === Database.libraryFilterData[libraryId]?.seriesCount && authorCountFromDatabase === Database.libraryFilterData[libraryId].authorCount) { Logger.debug(`Filter data for ${libraryId} has not changed, returning cached data and updating cache time after ${((Date.now() - start) / 1000).toFixed(2)}s`) Database.libraryFilterData[libraryId].loadedAt = Date.now() return cachedFilterData