feat(torrents): add tracker controls

This commit is contained in:
NimBold
2026-08-01 23:53:07 +03:30
parent e31a3fcc90
commit 0f1f4e8003
20 changed files with 434 additions and 15 deletions
+7 -3
View File
@@ -853,12 +853,14 @@ describe('useDownloadStore', () => {
isTorrent: true,
torrentMaxPeers: 'not-a-number' as unknown as number,
torrentPeerSpeedLimit: 0 as unknown as string,
torrentCheckIntegrity: 'yes' as unknown as boolean
torrentCheckIntegrity: 'yes' as unknown as boolean,
torrentTrackers: 123 as unknown as string
});
expect(normalized.torrentMaxPeers).toBeUndefined();
expect(normalized.torrentPeerSpeedLimit).toBeUndefined();
expect(normalized.torrentCheckIntegrity).toBeUndefined();
expect(normalized.torrentTrackers).toBeUndefined();
});
it('normalizes proxy settings for download dispatch', async () => {
@@ -1509,7 +1511,8 @@ describe('useDownloadStore', () => {
category: 'Other',
dateAdded: '',
isTorrent: true,
torrentCheckIntegrity: true
torrentCheckIntegrity: true,
torrentTrackers: 'https://tracker.example/announce'
}, { type: 'start-now' });
const item = useDownloadStore.getState().downloads[0];
@@ -1520,7 +1523,8 @@ describe('useDownloadStore', () => {
expect.objectContaining({
item: expect.objectContaining({
id: 'start-1',
torrent_check_integrity: true
torrent_check_integrity: true,
torrent_trackers: 'https://tracker.example/announce'
})
})
);
+10 -2
View File
@@ -351,6 +351,7 @@ async function dispatchItemInternal(id: string, proxyOverride?: string | null):
torrent_max_peers: item.torrentMaxPeers,
torrent_peer_speed_limit: item.torrentPeerSpeedLimit || undefined,
torrent_check_integrity: item.torrentCheckIntegrity,
torrent_trackers: item.torrentTrackers || undefined,
lifecycle_generation: lifecycleGeneration.toString(),
};
@@ -631,14 +632,20 @@ export const normalizePersistedDownloadProgress = (download: DownloadItem): Down
const normalizedCheckIntegrity = typeof rawCheckIntegrity === 'boolean'
? rawCheckIntegrity
: undefined;
const rawTrackers = download.torrentTrackers as unknown;
const normalizedTrackers = typeof rawTrackers === 'string' && rawTrackers.trim()
? rawTrackers.trim()
: undefined;
const normalizedOptions = rawMaxPeers !== normalizedMaxPeers ||
rawPeerSpeedLimit !== normalizedPeerSpeedLimit ||
rawCheckIntegrity !== normalizedCheckIntegrity
rawCheckIntegrity !== normalizedCheckIntegrity ||
rawTrackers !== normalizedTrackers
? {
...download,
torrentMaxPeers: normalizedMaxPeers,
torrentPeerSpeedLimit: normalizedPeerSpeedLimit,
torrentCheckIntegrity: normalizedCheckIntegrity
torrentCheckIntegrity: normalizedCheckIntegrity,
torrentTrackers: normalizedTrackers
}
: download;
@@ -2170,6 +2177,7 @@ export const useDownloadStore = create<DownloadState>((set, get) => {
torrent_max_peers: item.torrentMaxPeers,
torrent_peer_speed_limit: item.torrentPeerSpeedLimit || undefined,
torrent_check_integrity: item.torrentCheckIntegrity,
torrent_trackers: item.torrentTrackers || undefined,
lifecycle_generation: currentDownloadLifecycle(item.id).toString(),
});
}