mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-17 14:57:49 +00:00
feat(torrents): add tracker timing controls
This commit is contained in:
@@ -856,6 +856,9 @@ describe('useDownloadStore', () => {
|
||||
torrentCheckIntegrity: 'yes' as unknown as boolean,
|
||||
torrentTrackers: 123 as unknown as string,
|
||||
torrentExcludeTrackers: 123 as unknown as string,
|
||||
torrentTrackerConnectTimeout: 0,
|
||||
torrentTrackerTimeout: 604801,
|
||||
torrentTrackerInterval: -1,
|
||||
torrentStopTimeout: 604801,
|
||||
torrentPrioritizePiece: 'head=1G',
|
||||
torrentRemoveUnselectedFile: 'yes' as unknown as boolean,
|
||||
@@ -867,6 +870,9 @@ describe('useDownloadStore', () => {
|
||||
expect(normalized.torrentCheckIntegrity).toBeUndefined();
|
||||
expect(normalized.torrentTrackers).toBeUndefined();
|
||||
expect(normalized.torrentExcludeTrackers).toBeUndefined();
|
||||
expect(normalized.torrentTrackerConnectTimeout).toBeUndefined();
|
||||
expect(normalized.torrentTrackerTimeout).toBeUndefined();
|
||||
expect(normalized.torrentTrackerInterval).toBeUndefined();
|
||||
expect(normalized.torrentStopTimeout).toBeUndefined();
|
||||
expect(normalized.torrentPrioritizePiece).toBeUndefined();
|
||||
expect(normalized.torrentRemoveUnselectedFile).toBeUndefined();
|
||||
@@ -1524,6 +1530,9 @@ describe('useDownloadStore', () => {
|
||||
torrentCheckIntegrity: true,
|
||||
torrentTrackers: 'https://tracker.example/announce',
|
||||
torrentExcludeTrackers: '*',
|
||||
torrentTrackerConnectTimeout: 11,
|
||||
torrentTrackerTimeout: 22,
|
||||
torrentTrackerInterval: 33,
|
||||
torrentStopTimeout: 300,
|
||||
torrentPrioritizePiece: 'head=1M,tail=1M',
|
||||
torrentEncryptionPolicy: 'force-encryption',
|
||||
@@ -1542,6 +1551,9 @@ describe('useDownloadStore', () => {
|
||||
torrent_check_integrity: true,
|
||||
torrent_trackers: 'https://tracker.example/announce',
|
||||
torrent_exclude_trackers: '*',
|
||||
torrent_tracker_connect_timeout: 11,
|
||||
torrent_tracker_timeout: 22,
|
||||
torrent_tracker_interval: 33,
|
||||
torrent_stop_timeout: 300,
|
||||
torrent_prioritize_piece: 'head=1M,tail=1M',
|
||||
torrent_encryption_policy: 'force-encryption',
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { ExtensionCookieScope } from '../bindings/ExtensionCookieScope';
|
||||
import type { Queue } from '../bindings/Queue';
|
||||
import { useSettingsStore } from './useSettingsStore';
|
||||
import { useDownloadProgressStore } from './downloadProgressStore';
|
||||
import { canonicalizeDownloadFileName, categoryForFileName, isActiveDownloadStatus, isTransferActiveStatus, isValidTorrentExcludeTrackerList, isValidTorrentTrackerList, MAX_TORRENT_STOP_TIMEOUT, normalizeSpeedLimitForBackend, normalizeTorrentEncryptionPolicy, normalizeTorrentPrioritizePiece, redactDownloadForPersistence, resolveDownloadConnections } from '../utils/downloads';
|
||||
import { canonicalizeDownloadFileName, categoryForFileName, isActiveDownloadStatus, isTransferActiveStatus, isValidTorrentExcludeTrackerList, isValidTorrentTrackerList, MAX_TORRENT_STOP_TIMEOUT, normalizeSpeedLimitForBackend, normalizeTorrentEncryptionPolicy, normalizeTorrentPrioritizePiece, normalizeTorrentTrackerInterval, normalizeTorrentTrackerTimeout, redactDownloadForPersistence, resolveDownloadConnections } from '../utils/downloads';
|
||||
import {
|
||||
resolveCategoryDestination
|
||||
} from '../utils/downloadLocations';
|
||||
@@ -353,6 +353,9 @@ async function dispatchItemInternal(id: string, proxyOverride?: string | null):
|
||||
torrent_check_integrity: item.torrentCheckIntegrity,
|
||||
torrent_trackers: item.torrentTrackers || undefined,
|
||||
torrent_exclude_trackers: item.torrentExcludeTrackers || undefined,
|
||||
torrent_tracker_connect_timeout: item.torrentTrackerConnectTimeout,
|
||||
torrent_tracker_timeout: item.torrentTrackerTimeout,
|
||||
torrent_tracker_interval: item.torrentTrackerInterval,
|
||||
torrent_stop_timeout: item.torrentStopTimeout,
|
||||
torrent_prioritize_piece: item.torrentPrioritizePiece || undefined,
|
||||
torrent_remove_unselected_file: item.torrentRemoveUnselectedFile,
|
||||
@@ -645,6 +648,12 @@ export const normalizePersistedDownloadProgress = (download: DownloadItem): Down
|
||||
const normalizedExcludeTrackers = typeof rawExcludeTrackers === 'string' && rawExcludeTrackers.trim() && isValidTorrentExcludeTrackerList(rawExcludeTrackers)
|
||||
? rawExcludeTrackers.trim()
|
||||
: undefined;
|
||||
const rawTrackerConnectTimeout = download.torrentTrackerConnectTimeout as unknown;
|
||||
const normalizedTrackerConnectTimeout = normalizeTorrentTrackerTimeout(rawTrackerConnectTimeout);
|
||||
const rawTrackerTimeout = download.torrentTrackerTimeout as unknown;
|
||||
const normalizedTrackerTimeout = normalizeTorrentTrackerTimeout(rawTrackerTimeout);
|
||||
const rawTrackerInterval = download.torrentTrackerInterval as unknown;
|
||||
const normalizedTrackerInterval = normalizeTorrentTrackerInterval(rawTrackerInterval);
|
||||
const rawStopTimeout = download.torrentStopTimeout as unknown;
|
||||
const normalizedStopTimeout = typeof rawStopTimeout === 'number' &&
|
||||
Number.isInteger(rawStopTimeout) &&
|
||||
@@ -667,6 +676,9 @@ export const normalizePersistedDownloadProgress = (download: DownloadItem): Down
|
||||
rawCheckIntegrity !== normalizedCheckIntegrity ||
|
||||
rawTrackers !== normalizedTrackers ||
|
||||
rawExcludeTrackers !== normalizedExcludeTrackers ||
|
||||
rawTrackerConnectTimeout !== normalizedTrackerConnectTimeout ||
|
||||
rawTrackerTimeout !== normalizedTrackerTimeout ||
|
||||
rawTrackerInterval !== normalizedTrackerInterval ||
|
||||
rawStopTimeout !== normalizedStopTimeout ||
|
||||
rawPrioritizePiece !== normalizedPrioritizePiece ||
|
||||
rawRemoveUnselectedFile !== normalizedRemoveUnselectedFile ||
|
||||
@@ -678,6 +690,9 @@ export const normalizePersistedDownloadProgress = (download: DownloadItem): Down
|
||||
torrentCheckIntegrity: normalizedCheckIntegrity,
|
||||
torrentTrackers: normalizedTrackers,
|
||||
torrentExcludeTrackers: normalizedExcludeTrackers,
|
||||
torrentTrackerConnectTimeout: normalizedTrackerConnectTimeout,
|
||||
torrentTrackerTimeout: normalizedTrackerTimeout,
|
||||
torrentTrackerInterval: normalizedTrackerInterval,
|
||||
torrentStopTimeout: normalizedStopTimeout,
|
||||
torrentPrioritizePiece: normalizedPrioritizePiece,
|
||||
torrentRemoveUnselectedFile: normalizedRemoveUnselectedFile,
|
||||
@@ -2215,6 +2230,9 @@ export const useDownloadStore = create<DownloadState>((set, get) => {
|
||||
torrent_check_integrity: item.torrentCheckIntegrity,
|
||||
torrent_trackers: item.torrentTrackers || undefined,
|
||||
torrent_exclude_trackers: item.torrentExcludeTrackers || undefined,
|
||||
torrent_tracker_connect_timeout: item.torrentTrackerConnectTimeout,
|
||||
torrent_tracker_timeout: item.torrentTrackerTimeout,
|
||||
torrent_tracker_interval: item.torrentTrackerInterval,
|
||||
torrent_stop_timeout: item.torrentStopTimeout,
|
||||
torrent_prioritize_piece: item.torrentPrioritizePiece || undefined,
|
||||
torrent_remove_unselected_file: item.torrentRemoveUnselectedFile,
|
||||
|
||||
Reference in New Issue
Block a user