fix: prevent background Laya rebuilds during playback

Ensure automatic live projection rebuilds use the algorithmic path so Laya identity batches are not launched during live list playback or background sync.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
blomios
2026-10-07 22:44:05 +02:00
parent 281a47124e
commit ba5b1b37a1
4 changed files with 188 additions and 6 deletions

View File

@ -43,7 +43,7 @@ router.get('/channels', requireAuth, async (req, res) => {
try {
let state = liveProjection.projectionState();
if (state.status !== 'success' && state.status !== 'building') {
state = await liveProjection.startRebuild().promise;
state = await liveProjection.startRebuild(null, { mode: 'algo' }).promise;
}
const epgSources = await sources.getByType('epg');
const { channels, availableLanguages } = liveProjection.getChannelPage({

View File

@ -323,14 +323,17 @@ let activeState = null;
function startRebuild(database = null, options = {}) {
if (activeRebuild) return { alreadyRunning: true, state: activeState, promise: activeRebuild };
database ||= defaultDatabase();
const mark = options.mark || markProjectionBuilding;
const runner = options.runner || rebuildWithSignals;
const schedule = options.schedule || setImmediate;
const {
mark = markProjectionBuilding,
runner = rebuildWithSignals,
schedule = setImmediate,
...rebuildOptions
} = options;
activeState = mark(database);
activeRebuild = new Promise((resolve, reject) => {
schedule(() => {
Promise.resolve()
.then(() => runner(database, { stateAlreadyBuilding: true }))
.then(() => runner(database, { ...rebuildOptions, stateAlreadyBuilding: true }))
.then(resolve, reject);
});
}).finally(() => {
@ -341,7 +344,7 @@ function startRebuild(database = null, options = {}) {
}
function queueRebuild(database = null) {
return startRebuild(database).promise;
return startRebuild(database, { mode: 'algo' }).promise;
}
function parseData(value) {