mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-22 17:06:40 +00:00
feat(torrents): add stall timeout control
This commit is contained in:
@@ -13,7 +13,7 @@ import { FolderPlus, Save, Settings, Shield, RefreshCw, FileText, HardDrive, Dat
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
import { invokeCommand as invoke } from '../ipc';
|
||||
import { DuplicateResolutionModal, DuplicateConflict } from './DuplicateResolutionModal';
|
||||
import { canonicalizeDownloadFileName, categoryForFileName, downloadFileNameWithSuffix, downloadFileNamesMatch, downloadMediaKindsMatch, isValidTorrentTrackerList, normalizeSpeedLimitForBackend } from '../utils/downloads';
|
||||
import { canonicalizeDownloadFileName, categoryForFileName, downloadFileNameWithSuffix, downloadFileNamesMatch, downloadMediaKindsMatch, isValidTorrentTrackerList, MAX_TORRENT_STOP_TIMEOUT, normalizeSpeedLimitForBackend } from '../utils/downloads';
|
||||
import { fetchMediaMetadataDeduped, fetchMediaPlaylistMetadataDeduped } from '../utils/mediaMetadata';
|
||||
import {
|
||||
expandTilde,
|
||||
@@ -234,6 +234,7 @@ export const AddDownloadsModal = () => {
|
||||
const [torrentPeerSpeedLimit, setTorrentPeerSpeedLimit] = useState('');
|
||||
const [torrentCheckIntegrity, setTorrentCheckIntegrity] = useState(false);
|
||||
const [torrentTrackers, setTorrentTrackers] = useState('');
|
||||
const [torrentStopTimeout, setTorrentStopTimeout] = useState('0');
|
||||
const [freeSpace, setFreeSpace] = useState('Unknown');
|
||||
const freeSpaceRequestRef = useRef(0);
|
||||
|
||||
@@ -376,6 +377,7 @@ export const AddDownloadsModal = () => {
|
||||
setTorrentPeerSpeedLimit('');
|
||||
setTorrentCheckIntegrity(false);
|
||||
setTorrentTrackers('');
|
||||
setTorrentStopTimeout('0');
|
||||
setUseAuth(false);
|
||||
setUsername('');
|
||||
setPassword('');
|
||||
@@ -976,6 +978,14 @@ export const AddDownloadsModal = () => {
|
||||
addToast({ message: t($ => $.addDownloads.torrentTrackersInvalid), variant: 'error', isActionable: true });
|
||||
return;
|
||||
}
|
||||
if (
|
||||
hasSelectedTorrent
|
||||
&& torrentStopTimeout.trim()
|
||||
&& (!Number.isInteger(Number(torrentStopTimeout)) || Number(torrentStopTimeout) < 0 || Number(torrentStopTimeout) > MAX_TORRENT_STOP_TIMEOUT)
|
||||
) {
|
||||
addToast({ message: t($ => $.addDownloads.torrentStopTimeoutInvalid), variant: 'error', isActionable: true });
|
||||
return;
|
||||
}
|
||||
if (saveInDedicatedFolder && !sanitizeBatchFolderName(dedicatedFolderName)) {
|
||||
addToast({
|
||||
message: t($ => $.addDownloads.dedicatedFolderNameRequired),
|
||||
@@ -1456,6 +1466,7 @@ export const AddDownloadsModal = () => {
|
||||
: undefined,
|
||||
torrentCheckIntegrity: item.isTorrent ? torrentCheckIntegrity : undefined,
|
||||
torrentTrackers: item.isTorrent ? torrentTrackers.trim() || undefined : undefined,
|
||||
torrentStopTimeout: item.isTorrent && torrentStopTimeout.trim() ? Number(torrentStopTimeout) : undefined,
|
||||
size: item.size || (item.sizeBytes ? formatBytes(item.sizeBytes) : undefined),
|
||||
sizeBytes: item.sizeBytes
|
||||
}, action);
|
||||
@@ -2166,6 +2177,28 @@ export const AddDownloadsModal = () => {
|
||||
{t($ => $.addDownloads.torrentPeerOptionsHint)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-[1fr_auto] gap-2 items-center pt-2 border-t border-border-modal/50">
|
||||
<label htmlFor="torrent-stop-timeout" className="text-text-muted">
|
||||
{t($ => $.addDownloads.torrentStopTimeout)}
|
||||
</label>
|
||||
<div className="flex items-center gap-1">
|
||||
<input
|
||||
id="torrent-stop-timeout"
|
||||
type="number"
|
||||
min={0}
|
||||
max={MAX_TORRENT_STOP_TIMEOUT}
|
||||
step={1}
|
||||
value={torrentStopTimeout}
|
||||
onChange={event => setTorrentStopTimeout(event.currentTarget.value)}
|
||||
className="app-control w-24 px-2 py-1 text-end font-mono"
|
||||
aria-describedby="torrent-stop-timeout-hint"
|
||||
/>
|
||||
<span className="text-[10px] text-text-muted">{t($ => $.addDownloads.seconds)}</span>
|
||||
</div>
|
||||
<p id="torrent-stop-timeout-hint" className="col-span-2 text-[10px] text-text-muted">
|
||||
{t($ => $.addDownloads.torrentStopTimeoutHint)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
formatDownloadTotal,
|
||||
resolveDownloadSizeDisplay
|
||||
} from '../utils/downloadProgress';
|
||||
import { isValidTorrentTrackerList, normalizeSpeedLimitForBackend, resolveDownloadConnections } from '../utils/downloads';
|
||||
import { isValidTorrentTrackerList, MAX_TORRENT_STOP_TIMEOUT, normalizeSpeedLimitForBackend, resolveDownloadConnections } from '../utils/downloads';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { formatDateTime, type CalendarPreference } from '../utils/dateTime';
|
||||
import { isTopmostModal, useModalFocus } from '../hooks/useModalFocus';
|
||||
@@ -79,6 +79,7 @@ export const PropertiesModal = () => {
|
||||
const [liveTorrentPeerSpeedLimitValue, setLiveTorrentPeerSpeedLimitValue] = useState('');
|
||||
const [torrentCheckIntegrity, setTorrentCheckIntegrity] = useState(false);
|
||||
const [torrentTrackers, setTorrentTrackers] = useState('');
|
||||
const [torrentStopTimeout, setTorrentStopTimeout] = useState('0');
|
||||
const [isLiveSpeedLimitPending, setIsLiveSpeedLimitPending] = useState(false);
|
||||
const [isLiveTorrentUploadLimitPending, setIsLiveTorrentUploadLimitPending] = useState(false);
|
||||
const [isLiveTorrentPeerOptionsPending, setIsLiveTorrentPeerOptionsPending] = useState(false);
|
||||
@@ -172,6 +173,7 @@ export const PropertiesModal = () => {
|
||||
setLiveTorrentPeerSpeedLimitValue(activeItem.torrentPeerSpeedLimit || '');
|
||||
setTorrentCheckIntegrity(activeItem.torrentCheckIntegrity === true);
|
||||
setTorrentTrackers(activeItem.torrentTrackers || '');
|
||||
setTorrentStopTimeout(activeItem.torrentStopTimeout === undefined ? '0' : String(activeItem.torrentStopTimeout));
|
||||
setErrorMessage('');
|
||||
} else {
|
||||
setSelectedPropertiesDownloadId(null);
|
||||
@@ -271,6 +273,17 @@ export const PropertiesModal = () => {
|
||||
setErrorMessage(t($ => $.properties.torrentTrackersInvalid));
|
||||
return;
|
||||
}
|
||||
const normalizedStopTimeout = torrentStopTimeout.trim()
|
||||
? Number(torrentStopTimeout)
|
||||
: undefined;
|
||||
if (
|
||||
item.isTorrent
|
||||
&& normalizedStopTimeout !== undefined
|
||||
&& (!Number.isInteger(normalizedStopTimeout) || normalizedStopTimeout < 0 || normalizedStopTimeout > MAX_TORRENT_STOP_TIMEOUT)
|
||||
) {
|
||||
setErrorMessage(t($ => $.properties.torrentStopTimeoutInvalid));
|
||||
return;
|
||||
}
|
||||
|
||||
const updates: Partial<DownloadItem> = {
|
||||
url,
|
||||
@@ -289,6 +302,7 @@ export const PropertiesModal = () => {
|
||||
torrentPeerSpeedLimit: normalizedPeerSpeedLimit || undefined,
|
||||
torrentCheckIntegrity,
|
||||
torrentTrackers: torrentTrackers.trim() || undefined,
|
||||
torrentStopTimeout: normalizedStopTimeout,
|
||||
}
|
||||
: {}),
|
||||
...(connectionsDirty
|
||||
@@ -729,6 +743,29 @@ export const PropertiesModal = () => {
|
||||
{t($ => $.properties.torrentTrackersHint)}
|
||||
</p>
|
||||
</div>
|
||||
<label className="text-xs text-text-muted text-right" htmlFor="torrent-stop-timeout-properties">
|
||||
{t($ => $.properties.torrentStopTimeout)}
|
||||
</label>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
id="torrent-stop-timeout-properties"
|
||||
type="number"
|
||||
min={0}
|
||||
max={MAX_TORRENT_STOP_TIMEOUT}
|
||||
step={1}
|
||||
value={torrentStopTimeout}
|
||||
onChange={event => setTorrentStopTimeout(event.currentTarget.value)}
|
||||
disabled={transferLocked}
|
||||
aria-describedby="torrent-stop-timeout-properties-hint"
|
||||
className="app-control w-24 px-2.5 py-1.5 text-end text-xs font-mono disabled:opacity-50"
|
||||
/>
|
||||
<span className="text-[11px] text-text-muted">{t($ => $.properties.seconds)}</span>
|
||||
</div>
|
||||
<p id="torrent-stop-timeout-properties-hint" className="mt-1 text-[11px] text-text-muted">
|
||||
{t($ => $.properties.torrentStopTimeoutHint)}
|
||||
</p>
|
||||
</div>
|
||||
<label className="text-xs text-text-muted text-right" htmlFor="torrent-check-integrity">
|
||||
{t($ => $.properties.torrentVerifyIntegrity)}
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user