Compare commits

..

3 Commits

Author SHA1 Message Date
advplyr
5ca12eee19 Fix count cache by stringify Symbols #3979 2025-02-13 18:07:59 -06:00
advplyr
ebdf377fc1 Version bump v2.19.2 2025-02-12 10:01:05 -06:00
advplyr
808d23561c Merge pull request #3972 from advplyr/remove-col-ambiguity
Fix server crash remove column name ambiguity #3966
2025-02-12 09:59:54 -06:00
6 changed files with 43 additions and 8 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "audiobookshelf-client",
"version": "2.19.1",
"version": "2.19.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "audiobookshelf-client",
"version": "2.19.1",
"version": "2.19.2",
"license": "ISC",
"dependencies": {
"@nuxtjs/axios": "^5.13.6",

View File

@@ -1,6 +1,6 @@
{
"name": "audiobookshelf-client",
"version": "2.19.1",
"version": "2.19.2",
"buildNumber": 1,
"description": "Self-hosted audiobook and podcast client",
"main": "index.js",

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "audiobookshelf",
"version": "2.19.1",
"version": "2.19.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "audiobookshelf",
"version": "2.19.1",
"version": "2.19.2",
"license": "GPL-3.0",
"dependencies": {
"axios": "^0.27.2",

View File

@@ -1,6 +1,6 @@
{
"name": "audiobookshelf",
"version": "2.19.1",
"version": "2.19.2",
"buildNumber": 1,
"description": "Self-hosted audiobook and podcast server",
"main": "index.js",

View File

@@ -5,7 +5,7 @@ const authorFilters = require('./authorFilters')
const ShareManager = require('../../managers/ShareManager')
const { profile } = require('../profiler')
const stringifySequelizeQuery = require('../stringifySequelizeQuery')
const countCache = new Map()
module.exports = {
@@ -345,7 +345,7 @@ module.exports = {
},
async findAndCountAll(findOptions, limit, offset) {
const findOptionsKey = JSON.stringify(findOptions)
const findOptionsKey = stringifySequelizeQuery(findOptions)
Logger.debug(`[LibraryItemsBookFilters] findOptionsKey: ${findOptionsKey}`)
findOptions.limit = limit || null
@@ -353,6 +353,7 @@ module.exports = {
if (countCache.has(findOptionsKey)) {
const rows = await Database.bookModel.findAll(findOptions)
return { rows, count: countCache.get(findOptionsKey) }
} else {
const result = await Database.bookModel.findAndCountAll(findOptions)

View File

@@ -0,0 +1,34 @@
function stringifySequelizeQuery(findOptions) {
// Helper function to handle symbols in nested objects
function handleSymbols(obj) {
if (!obj || typeof obj !== 'object') return obj
if (Array.isArray(obj)) {
return obj.map(handleSymbols)
}
const newObj = {}
for (const [key, value] of Object.entries(obj)) {
// Handle Symbol keys from Object.getOwnPropertySymbols
Object.getOwnPropertySymbols(obj).forEach((sym) => {
newObj[`__Op.${sym.toString()}`] = handleSymbols(obj[sym])
})
// Handle regular keys
if (typeof key === 'string') {
if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Symbol.prototype) {
// Handle Symbol values
newObj[key] = `__Op.${value.toString()}`
} else {
// Recursively handle nested objects
newObj[key] = handleSymbols(value)
}
}
}
return newObj
}
const sanitizedOptions = handleSymbols(findOptions)
return JSON.stringify(sanitizedOptions)
}
module.exports = stringifySequelizeQuery