fix: address post-audit regressions across queue, db, and ui

- Preserved extension-captured cookies through the Add modal, with a clean fallback when captured cookies break metadata fetching.
- Prevented batched extension captures from losing URLs or reusing stale cookie/header contexts.
- Fixed pause/resume and enqueue generation races, including cancellation during queue reservation and replay after task removal.
- Made startup database initialization safe under React StrictMode.
- Serialized keyring operations and corrected Linux legacy migration/deletion behavior.
- Restored `Downloading` state after yt-dlp retries.
- Replaced hardcoded media heights with dynamically detected formats, including nonstandard qualities such as 576p and 2880p.
This commit is contained in:
NimBold
2026-07-10 12:07:25 +03:30
parent 3fbd0742be
commit 4f4c655de6
11 changed files with 550 additions and 186 deletions
+18 -3
View File
@@ -37,6 +37,20 @@ const waitForSettingsHydration = (): Promise<void> => {
});
};
let downloadStateInitialization: Promise<void> | null = null;
const initializeDownloadState = (): Promise<void> => {
if (!downloadStateInitialization) {
downloadStateInitialization = (async () => {
await waitForSettingsHydration();
await useDownloadStore.getState().initDB();
})().catch(error => {
downloadStateInitialization = null;
throw error;
});
}
return downloadStateInitialization;
};
const getScheduledQueueIds = () => {
const downloadState = useDownloadStore.getState();
const availableQueueIds = new Set(downloadState.queues.map(queue => queue.id));
@@ -227,10 +241,11 @@ function App() {
let active = true;
const initialize = async () => {
try {
await waitForSettingsHydration();
await useDownloadStore.getState().initDB();
if (active) setCoreReady(true);
await initializeDownloadState();
if (!active) return;
setCoreReady(true);
} catch (error) {
if (!active) return;
console.error('Failed to initialize Firelink state:', error);
addToast({
message: `Could not initialize saved downloads: ${String(error)}`,