Deep search: pass the database client, not the db module, so start/jobs/estimate stop returning 500

This commit is contained in:
Jonathan Sykes
2026-10-15 16:41:25 +08:00
parent e8982162c0
commit dbcee5d5f8
2 changed files with 3 additions and 1 deletions

View File

@@ -44,6 +44,8 @@ function publicJob(row, indexSize = 0) {
export function createDeepSearchService({ db = defaultDb, searchDeep = innertube.searchDeep, related = innertube.related,
browseUploads = innertube.browseUploads, ingest = catalog.ingest, putSearch = searchCache.put,
sleep = sleepDefault, random = Math.random, now = Date.now, autoStart = true } = {}) {
// Accept the db.js module namespace as well as the client itself.
if (typeof db?.execute !== 'function' && typeof db?.db?.execute === 'function') db = db.db;
let worker = null;
let timer = null;
const log = (state, message) => { state.log ||= []; state.log.push({ at: now(), message: String(message).slice(0, 240) }); if (state.log.length > 100) state.log.splice(0, state.log.length - 100); };