Add Transmission/NZBGet and per-client paths and much more

Extend multi-download-client support to include Transmission and NZBGet and introduce per-client custom download paths. Adds protocol mapping and new client types, Transmission/NZBGet integration services, API CRUD and validation changes, UI components/modal updates and live path previews, and manager routing by protocol. Includes DB migrations (download_path on download_history, interactive_search_access on users), schema updates, and related processor/service fixes and tests to ensure backward compatibility and proper path resolution.
This commit is contained in:
kikootwo
2026-02-09 19:45:43 -05:00
parent d7acd67aa4
commit 4b90b35748
117 changed files with 9346 additions and 1488 deletions
+26 -9
View File
@@ -14,6 +14,9 @@ const requireAdminMock = vi.hoisted(() => vi.fn());
const configServiceMock = vi.hoisted(() => ({ get: vi.fn() }));
const qbittorrentMock = vi.hoisted(() => ({ getTorrent: vi.fn() }));
const sabnzbdMock = vi.hoisted(() => ({ getNZB: vi.fn() }));
const downloadClientManagerMock = vi.hoisted(() => ({
getClientServiceForProtocol: vi.fn(),
}));
vi.mock('@/lib/db', () => ({
prisma: prismaMock,
@@ -36,12 +39,17 @@ vi.mock('@/lib/integrations/sabnzbd.service', () => ({
getSABnzbdService: async () => sabnzbdMock,
}));
vi.mock('@/lib/services/download-client-manager.service', () => ({
getDownloadClientManager: () => downloadClientManagerMock,
}));
describe('Admin downloads route', () => {
beforeEach(() => {
vi.clearAllMocks();
authRequest = { user: { id: 'admin-1', role: 'admin' } };
requireAuthMock.mockImplementation((_req: any, handler: any) => handler(authRequest));
requireAdminMock.mockImplementation((_req: any, handler: any) => handler());
downloadClientManagerMock.getClientServiceForProtocol.mockReset();
});
it('returns formatted active downloads', async () => {
@@ -53,11 +61,15 @@ describe('Admin downloads route', () => {
updatedAt: new Date(),
audiobook: { title: 'Title', author: 'Author' },
user: { plexUsername: 'user' },
downloadHistory: [{ torrentHash: 'hash', torrentName: 'Torrent', downloadStatus: 'downloading' }],
downloadHistory: [{ torrentHash: 'hash', torrentName: 'Torrent', downloadStatus: 'downloading', downloadClient: 'qbittorrent' }],
},
]);
configServiceMock.get.mockResolvedValueOnce('qbittorrent');
qbittorrentMock.getTorrent.mockResolvedValueOnce({ dlspeed: 123, eta: 60 });
downloadClientManagerMock.getClientServiceForProtocol.mockResolvedValueOnce({
getDownload: vi.fn().mockResolvedValue({
downloadSpeed: 123,
eta: 60,
}),
});
const { GET } = await import('@/app/api/admin/downloads/active/route');
const response = await GET({} as any);
@@ -76,11 +88,15 @@ describe('Admin downloads route', () => {
updatedAt: new Date(),
audiobook: { title: 'Title', author: 'Author' },
user: { plexUsername: 'user' },
downloadHistory: [{ nzbId: 'nzb-1', torrentName: 'NZB', downloadStatus: 'downloading' }],
downloadHistory: [{ nzbId: 'nzb-1', torrentName: 'NZB', downloadStatus: 'downloading', downloadClient: 'sabnzbd' }],
},
]);
configServiceMock.get.mockResolvedValueOnce('sabnzbd');
sabnzbdMock.getNZB.mockResolvedValueOnce({ downloadSpeed: 555, timeLeft: 120 });
downloadClientManagerMock.getClientServiceForProtocol.mockResolvedValueOnce({
getDownload: vi.fn().mockResolvedValue({
downloadSpeed: 555,
eta: 120,
}),
});
const { GET } = await import('@/app/api/admin/downloads/active/route');
const response = await GET({} as any);
@@ -99,11 +115,12 @@ describe('Admin downloads route', () => {
updatedAt: new Date(),
audiobook: { title: 'Title', author: 'Author' },
user: { plexUsername: 'user' },
downloadHistory: [{ torrentHash: 'hash', torrentName: 'Torrent', downloadStatus: 'downloading' }],
downloadHistory: [{ torrentHash: 'hash', torrentName: 'Torrent', downloadStatus: 'downloading', downloadClient: 'qbittorrent' }],
},
]);
configServiceMock.get.mockResolvedValueOnce('qbittorrent');
qbittorrentMock.getTorrent.mockRejectedValueOnce(new Error('client down'));
downloadClientManagerMock.getClientServiceForProtocol.mockResolvedValueOnce({
getDownload: vi.fn().mockRejectedValue(new Error('client down')),
});
const { GET } = await import('@/app/api/admin/downloads/active/route');
const response = await GET({} as any);