mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-10 11:37:21 +00:00
feat(torrents): add integrity verification policy
This commit is contained in:
@@ -852,11 +852,13 @@ describe('useDownloadStore', () => {
|
||||
dateAdded: '',
|
||||
isTorrent: true,
|
||||
torrentMaxPeers: 'not-a-number' as unknown as number,
|
||||
torrentPeerSpeedLimit: 0 as unknown as string
|
||||
torrentPeerSpeedLimit: 0 as unknown as string,
|
||||
torrentCheckIntegrity: 'yes' as unknown as boolean
|
||||
});
|
||||
|
||||
expect(normalized.torrentMaxPeers).toBeUndefined();
|
||||
expect(normalized.torrentPeerSpeedLimit).toBeUndefined();
|
||||
expect(normalized.torrentCheckIntegrity).toBeUndefined();
|
||||
});
|
||||
|
||||
it('normalizes proxy settings for download dispatch', async () => {
|
||||
@@ -1505,7 +1507,9 @@ describe('useDownloadStore', () => {
|
||||
url: 'https://example.com/start.bin',
|
||||
fileName: 'start.bin',
|
||||
category: 'Other',
|
||||
dateAdded: ''
|
||||
dateAdded: '',
|
||||
isTorrent: true,
|
||||
torrentCheckIntegrity: true
|
||||
}, { type: 'start-now' });
|
||||
|
||||
const item = useDownloadStore.getState().downloads[0];
|
||||
@@ -1514,7 +1518,10 @@ describe('useDownloadStore', () => {
|
||||
expect(ipc.invokeCommand).toHaveBeenCalledWith(
|
||||
'enqueue_download',
|
||||
expect.objectContaining({
|
||||
item: expect.objectContaining({ id: 'start-1' })
|
||||
item: expect.objectContaining({
|
||||
id: 'start-1',
|
||||
torrent_check_integrity: true
|
||||
})
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -350,6 +350,7 @@ async function dispatchItemInternal(id: string, proxyOverride?: string | null):
|
||||
torrent_upload_limit: item.torrentUploadLimit || undefined,
|
||||
torrent_max_peers: item.torrentMaxPeers,
|
||||
torrent_peer_speed_limit: item.torrentPeerSpeedLimit || undefined,
|
||||
torrent_check_integrity: item.torrentCheckIntegrity,
|
||||
lifecycle_generation: lifecycleGeneration.toString(),
|
||||
};
|
||||
|
||||
@@ -626,12 +627,18 @@ export const normalizePersistedDownloadProgress = (download: DownloadItem): Down
|
||||
const normalizedPeerSpeedLimit = typeof rawPeerSpeedLimit === 'string'
|
||||
? normalizeSpeedLimitForBackend(rawPeerSpeedLimit) || undefined
|
||||
: undefined;
|
||||
const rawCheckIntegrity = download.torrentCheckIntegrity as unknown;
|
||||
const normalizedCheckIntegrity = typeof rawCheckIntegrity === 'boolean'
|
||||
? rawCheckIntegrity
|
||||
: undefined;
|
||||
const normalizedOptions = rawMaxPeers !== normalizedMaxPeers ||
|
||||
rawPeerSpeedLimit !== normalizedPeerSpeedLimit
|
||||
rawPeerSpeedLimit !== normalizedPeerSpeedLimit ||
|
||||
rawCheckIntegrity !== normalizedCheckIntegrity
|
||||
? {
|
||||
...download,
|
||||
torrentMaxPeers: normalizedMaxPeers,
|
||||
torrentPeerSpeedLimit: normalizedPeerSpeedLimit
|
||||
torrentPeerSpeedLimit: normalizedPeerSpeedLimit,
|
||||
torrentCheckIntegrity: normalizedCheckIntegrity
|
||||
}
|
||||
: download;
|
||||
|
||||
@@ -2162,6 +2169,7 @@ export const useDownloadStore = create<DownloadState>((set, get) => {
|
||||
torrent_upload_limit: item.torrentUploadLimit || undefined,
|
||||
torrent_max_peers: item.torrentMaxPeers,
|
||||
torrent_peer_speed_limit: item.torrentPeerSpeedLimit || undefined,
|
||||
torrent_check_integrity: item.torrentCheckIntegrity,
|
||||
lifecycle_generation: currentDownloadLifecycle(item.id).toString(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user