feat(torrents): add integrity verification policy

This commit is contained in:
NimBold
2026-08-01 22:53:37 +03:30
parent 87d682709e
commit e31a3fcc90
16 changed files with 210 additions and 8 deletions
+17
View File
@@ -232,6 +232,7 @@ export const AddDownloadsModal = () => {
const [torrentUploadLimit, setTorrentUploadLimit] = useState('1024');
const [torrentMaxPeers, setTorrentMaxPeers] = useState('');
const [torrentPeerSpeedLimit, setTorrentPeerSpeedLimit] = useState('');
const [torrentCheckIntegrity, setTorrentCheckIntegrity] = useState(false);
const [freeSpace, setFreeSpace] = useState('Unknown');
const freeSpaceRequestRef = useRef(0);
@@ -372,6 +373,7 @@ export const AddDownloadsModal = () => {
setTorrentUploadLimit('1024');
setTorrentMaxPeers('');
setTorrentPeerSpeedLimit('');
setTorrentCheckIntegrity(false);
setUseAuth(false);
setUsername('');
setPassword('');
@@ -1448,6 +1450,7 @@ export const AddDownloadsModal = () => {
torrentPeerSpeedLimit: item.isTorrent
? normalizeSpeedLimitForBackend(torrentPeerSpeedLimit) || undefined
: undefined,
torrentCheckIntegrity: item.isTorrent ? torrentCheckIntegrity : undefined,
size: item.size || (item.sizeBytes ? formatBytes(item.sizeBytes) : undefined),
sizeBytes: item.sizeBytes
}, action);
@@ -2094,6 +2097,20 @@ export const AddDownloadsModal = () => {
<span className="text-text-muted">KiB/s</span>
</div>
) : null}
<label className="flex items-start gap-2 text-text-primary pt-2 border-t border-border-modal/50">
<input
type="checkbox"
checked={torrentCheckIntegrity}
onChange={event => setTorrentCheckIntegrity(event.target.checked)}
className="accent-blue-500 mt-0.5"
/>
<span>
<span className="block">{t($ => $.addDownloads.torrentVerifyIntegrity)}</span>
<span className="block text-[10px] text-text-muted">
{t($ => $.addDownloads.torrentVerifyIntegrityHint)}
</span>
</span>
</label>
<div className="grid grid-cols-[1fr_auto] gap-2 items-center pt-2 border-t border-border-modal/50">
<label htmlFor="torrent-max-peers" className="text-text-muted">
{t($ => $.addDownloads.torrentMaxPeers)}
+20
View File
@@ -77,6 +77,7 @@ export const PropertiesModal = () => {
const [liveTorrentUploadLimitValue, setLiveTorrentUploadLimitValue] = useState('');
const [liveTorrentMaxPeersValue, setLiveTorrentMaxPeersValue] = useState('');
const [liveTorrentPeerSpeedLimitValue, setLiveTorrentPeerSpeedLimitValue] = useState('');
const [torrentCheckIntegrity, setTorrentCheckIntegrity] = useState(false);
const [isLiveSpeedLimitPending, setIsLiveSpeedLimitPending] = useState(false);
const [isLiveTorrentUploadLimitPending, setIsLiveTorrentUploadLimitPending] = useState(false);
const [isLiveTorrentPeerOptionsPending, setIsLiveTorrentPeerOptionsPending] = useState(false);
@@ -168,6 +169,7 @@ export const PropertiesModal = () => {
activeItem.torrentMaxPeers === undefined ? '' : String(activeItem.torrentMaxPeers)
);
setLiveTorrentPeerSpeedLimitValue(activeItem.torrentPeerSpeedLimit || '');
setTorrentCheckIntegrity(activeItem.torrentCheckIntegrity === true);
setErrorMessage('');
} else {
setSelectedPropertiesDownloadId(null);
@@ -279,6 +281,7 @@ export const PropertiesModal = () => {
? {
torrentMaxPeers: normalizedMaxPeers,
torrentPeerSpeedLimit: normalizedPeerSpeedLimit || undefined,
torrentCheckIntegrity,
}
: {}),
...(connectionsDirty
@@ -701,6 +704,23 @@ export const PropertiesModal = () => {
<div className="col-start-2 text-[11px] text-text-muted">
{t($ => $.properties.torrentPeerOptionsSavedHint)}
</div>
<label className="text-xs text-text-muted text-right" htmlFor="torrent-check-integrity">
{t($ => $.properties.torrentVerifyIntegrity)}
</label>
<label className="flex items-start gap-2 text-xs text-text-primary">
<input
id="torrent-check-integrity"
type="checkbox"
checked={torrentCheckIntegrity}
onChange={event => setTorrentCheckIntegrity(event.currentTarget.checked)}
disabled={transferLocked}
className="accent-accent mt-0.5 disabled:opacity-50"
aria-describedby="torrent-check-integrity-hint"
/>
<span id="torrent-check-integrity-hint" className="text-[11px] text-text-muted">
{t($ => $.properties.torrentVerifyIntegrityHint)}
</span>
</label>
</>
)}
{(liveSpeedLimitAvailable || liveSpeedLimitUnavailable) && (