fix(downloads): support offline fallback drafts

- launch Firefox handoffs through authenticated reconnect
- preserve usable drafts when metadata lookup fails
- reject stale metadata results and retry failed rows only
This commit is contained in:
NimBold
2026-06-22 17:21:47 +03:30
parent f469c5d7eb
commit 6b3753949b
10 changed files with 745 additions and 183 deletions
+31
View File
@@ -172,6 +172,37 @@ describe('useDownloadStore', () => {
);
});
it('redownloads fallback media without requiring a format selector', async () => {
useDownloadStore.setState({
downloads: [{
id: 'media-fallback',
url: 'https://youtube.com/watch?v=test',
fileName: 'watch',
destination: '/tmp',
status: 'completed',
category: 'Other',
dateAdded: '',
isMedia: true
}] as any[]
});
vi.mocked(ipc.invokeCommand).mockImplementation(async (cmd: string) => {
if (cmd === 'get_pending_order') return [];
return undefined;
});
await useDownloadStore.getState().redownload('media-fallback');
expect(ipc.invokeCommand).toHaveBeenCalledWith(
'enqueue_download',
expect.objectContaining({
item: expect.objectContaining({
is_media: true,
format_selector: null
})
})
);
});
it('starts and pauses all items regardless of legacy missing queue ids', async () => {
useDownloadStore.setState({
downloads: [
-3
View File
@@ -444,9 +444,6 @@ export const useDownloadStore = create<DownloadState>((set, get) => ({
}
const mediaFormatSelector = targetItem.mediaFormatSelector?.trim();
if (targetItem.isMedia && !mediaFormatSelector) {
throw new Error('Cannot redownload: selected media format is missing.');
}
const settings = useSettingsStore.getState();
const destPath = targetItem.destination ||