fix(mobile): delete cleanup audio files on retry and isolate screen busy state across user switches

This commit is contained in:
Yun Chan 2026-11-14 15:17:52 +09:00
parent bd3c1a98d9
commit cc3f7460be
5 changed files with 376 additions and 45 deletions

View file

@ -473,6 +473,17 @@ export async function processQueuedAudioNow(
return processItem(item);
}
async function finishCleanupItem(item: DurableQueueItem): Promise<void> {
try {
await removeOwnedFile(item.path);
await removeItem(item);
} catch {
if (!suspendedUsers.has(item.userId)) {
scheduler.arm(item.userId, Date.now() + 60_000);
}
}
}
/**
* One pass over the user's queue. The listing only fixes the visiting order;
* every item is re-read right before acting on it, so work done meanwhile by
@ -492,12 +503,7 @@ async function runResumePass(userId: string): Promise<void> {
if (item === undefined || item.userId !== userId) continue;
if (item.status === 'terminal') continue;
if (item.status === 'cleanup') {
try {
await removeOwnedFile(item.path);
await removeItem(item);
} catch {
scheduler.arm(userId, Date.now() + 60_000);
}
await finishCleanupItem(item);
continue;
}
if (item.nextAttemptAtMs > Date.now()) {
@ -532,7 +538,7 @@ export async function retryQueuedAudio(userId: string, itemId: string): Promise<
if (item === undefined) throw new AudioPipelineError('file-read', 'Queued audio was not found');
if (item.status === 'running' || runningItemPromises.has(item.id)) return;
if (item.status === 'cleanup') {
await removeItem(item);
await finishCleanupItem(item);
return;
}
await replaceItem({