fix(torrent): harden lifecycle and properties state

- admit valid magnets immediately while keeping metadata refresh optional
- fence Torrent recovery, diagnostics, and allocation presentation by lifecycle
- avoid false peer-wait claims when telemetry is missing or malformed
- stabilize Properties metric label/value layout for narrow and RTL windows

Tests:
- npm test -- --run
- npm run build
- npm run check:i18n
- node --test scripts/*.node-test.js
- cargo test --all-targets
- npm run smoke:torrent
- npm run smoke:torrent:failure-paths
- git diff --check
This commit is contained in:
NimBold
2026-08-24 15:51:24 +03:30
parent a6b341f9e3
commit b5ee53140d
20 changed files with 452 additions and 84 deletions
+18 -1
View File
@@ -12,6 +12,7 @@ import {
mediaTypeForFormat,
metadataSummaryMessage,
isYouTubePlaylistUrl,
isMagnetUrl,
isRemoteTorrentUrl,
playlistFilePrefix,
reconcileDownloadRows,
@@ -95,7 +96,7 @@ describe('add download metadata workflow', () => {
expect(rows[0]).toMatchObject({
isTorrent: true,
isMedia: false,
status: 'loading'
status: 'fallback'
});
expect(rows[1]).toMatchObject({
isTorrent: true,
@@ -105,6 +106,7 @@ describe('add download metadata workflow', () => {
});
expect(rows[0].torrentCacheId).toBe(`${rows[0].id}-1`);
expect(rows[1].torrentCacheId).toBe(`${rows[1].id}-1`);
expect(isMagnetUrl(rows[0].sourceUrl)).toBe(true);
});
it('admits remote .torrent URLs through the Torrent metadata path', () => {
@@ -533,6 +535,21 @@ describe('add download metadata workflow', () => {
expect(refreshed[1]).toMatchObject({ status: 'loading', generation: 5 });
});
it('refreshes an admitted magnet only when metadata is explicitly requested', () => {
const magnet = 'magnet:?xt=urn:btih:0123456789abcdef0123456789abcdef01234567';
const admitted = reconcileDownloadRows(magnet, [])[0];
expect(admitted.status).toBe('fallback');
expect(canSubmitMetadataRows([admitted])).toBe(true);
const refreshed = refreshFailedMetadataRows([admitted])[0];
expect(refreshed).toMatchObject({
status: 'loading',
generation: 2,
torrentCacheId: `${admitted.id}-2`,
});
});
it('ignores stale metadata results after generation changes', () => {
const current = row({ generation: 2, status: 'loading' });
const updated = updateRowIfCurrent(