Files
Twitch-VOD-Manager/src/main/domain/persistence-commit.ts
T
Sucukdeluxe 421da7be77 fix(persistence): serialize autosave generations before queue effects
Track settings input generations so an older asynchronous secret save cannot mark a newer value durable. Commit queue snapshots before cancellation, cleanup, or pause effects so SQLite failures leave runtime processes and files unchanged.
2026-08-12 00:38:49 +02:00

20 lines
514 B
TypeScript

export function persistStateChange<T>(current: T, createNext: (current: T) => T, persist: (next: T) => void): T {
const next = createNext(current);
persist(next);
return next;
}
export async function commitQueueMutation<T>(
current: T,
createNext: (current: T) => T,
persist: (next: T) => void,
apply: (next: T) => void,
effects: () => Promise<void>,
): Promise<T> {
const next = createNext(current);
persist(next);
apply(next);
await effects();
return next;
}