feat(torrents): add global open-file limit

This commit is contained in:
NimBold
2026-08-02 10:50:30 +03:30
parent 48b4d984a2
commit 2d427b96d3
19 changed files with 332 additions and 6 deletions
+14
View File
@@ -9,6 +9,7 @@ import {
isValidTorrentExcludeTrackerList,
isValidTorrentTrackerList,
normalizeTorrentEncryptionPolicy,
normalizeTorrentMaxOpenFiles,
normalizeTorrentPrioritizePiece,
normalizeTorrentTrackerInterval,
normalizeTorrentTrackerTimeout,
@@ -126,6 +127,19 @@ describe('Torrent tracker timing validation', () => {
});
});
describe('Torrent open-file limit validation', () => {
it('accepts bounded integer limits', () => {
expect(normalizeTorrentMaxOpenFiles(1)).toBe(1);
expect(normalizeTorrentMaxOpenFiles(4096)).toBe(4096);
});
it('rejects zero, fractional, and oversized limits', () => {
expect(normalizeTorrentMaxOpenFiles(0)).toBeUndefined();
expect(normalizeTorrentMaxOpenFiles('1.5')).toBeUndefined();
expect(normalizeTorrentMaxOpenFiles(4097)).toBeUndefined();
});
});
describe('download connection resolution', () => {
it('uses a clamped fallback for legacy rows without a saved value', () => {
expect(resolveDownloadConnections(undefined, 8)).toBe(8);