feat(queue): implement concurrent deduplication and safe backend detachment

- Add backendRegisteredIds and backendDispatchPromises for single dispatch enforcement

- Add detach_download_for_reconfigure to safely modify properties of active downloads

- Add applyProperties logic handling completed, failed, paused, and active queues

- Add extractValidDownloadUrls and fix multi-url paste handling

- Setup vitest and add useDownloadStore unit tests for backend registration lifecycle
This commit is contained in:
NimBold
2026-06-20 11:41:55 +03:30
parent 1660dd112d
commit 894c238bb7
17 changed files with 1058 additions and 312 deletions
+24
View File
@@ -0,0 +1,24 @@
export function extractValidDownloadUrls(text: string): string[] {
const lines = text.split('\n');
const urls: string[] = [];
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed) continue;
// Split by whitespace in case multiple URLs are on one line
const parts = trimmed.split(/\s+/);
for (const part of parts) {
try {
const url = new URL(part);
if (url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'ftp:') {
urls.push(url.toString());
}
} catch (e) {
// Not a valid URL
}
}
}
return [...new Set(urls)];
}